Tag: cllocationmanager

后台的StartUpdateLocations,didUpdatingToLocation只调用了10-20次

testing设备:iPhone 5(iOS 7) 我有一个使用RegionMonitoring和updateLocation的应用程序。 如果input区域, didEnterRegion预期调用didEnterRegion 。 然后我打电话给startUpdatingLocation 。 但是方法didUpdateToLocation只被调用10-20次,而它应该更新的位置,直到定时器触发。 相关代码: CLLocationManager *_locationManager; NSTimer *_timer; -(void)initLocationManager { _locationManager = [[CLLocationManager alloc] init]; _locationManager.delegate = self; [_locationManager setActivityType:CLActivityTypeOther]; [_locationManager setDesiredAccuracy:kCLLocationAccuracyBestForNavigation]; [_locationManager setPausesLocationUpdatesAutomatically:NO]; [_locationManager setDistanceFilter:kCLDistanceFilterNone]; } //Did Enter Region, called as expected: – (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { [_locationManager startUpdatingLocation]; _timer = [NSTimer scheduledTimerWithTimeInterval:300.0f target:self selector:@selector(scheduleMethod:) userInfo:nil […]

XCode / iOS模拟器:手动触发重要的位置更改

是否有办法手动告诉设备发送重要的位置更改通知,以唤醒为此通知注册的所有应用程序? 这只是为了testing,我意识到这个私人API调用将被提交到应用程序商店被拒绝。

CLLocationManager委托方法没有被调用(谷歌地图是集成的)

CLLocationManager的委托方法 didChangeAuthorizationStatus和didUpdateToLocation 没有被调用。 位置始终使用说明密钥已添加到info.plist中,并在第一次启动应用程序时收到通知。 我能够看到谷歌地图,但我无法看到当前的位置,当我改变位置,它没有得到更新。 Basicaaly委托方法没有被调用。 //码 import UIKit import GoogleMaps class ViewController: UIViewController,GMSMapViewDelegate { @IBOutlet weak var mapViewTest: GMSMapView! let locationManager = CLLocationManager() var currentLocation :CLLocation = CLLocation(latitude: 0.0, longitude: 0.0) var currentLatitude : Double = 0.0 var currentLongitude : Double = 0.0 override func viewDidLoad() { super.viewDidLoad()“ locationManager.delegate = self if (CLLocationManager.locationServicesEnabled()) { […]

Xcode 6 GM – CLLocationManager

我有一个使用Xcode 5制作的项目。我有一个ViewController,我使用CLLocationManager获取手机位置。 我已经实施了两个: -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations -(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 哪个效果很好。 现在我用Xcode 6 GM打开了这个项目,而这两个方法都没有被调用(不在模拟器或者设备上)。 有任何想法吗? 谢谢

如何在ios中多次停止didUpdateLocations()的方法调用

这个我的代码…… -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { location_updated = [locations lastObject]; NSLog(@"updated coordinate are %@",location_updated); latitude1 = location_updated.coordinate.latitude; longitude1 = location_updated.coordinate.longitude; self.lblLat.text = [NSString stringWithFormat:@"%f",latitude1]; self.lblLon.text = [NSString stringWithFormat:@"%f",longitude1]; NSString *str = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false",latitude1,longitude1]; url = [NSURL URLWithString:str]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; connection = [NSURLConnection connectionWithRequest:request delegate:self]; if (connection) { webData1 = [[NSMutableData alloc]init]; } […]

iOS:应用程序在安装应用程序时不会询问用户的权限。 每次都得到kCLAuthorizationStatusNotDetermined – Objective-c&Swift

我正在尝试在iOS应用程序中获取用户位置。 我首先在我的项目中包含了corelocation框架。 然后在一个button上单击我调用核心位置API如下。 当我试图在设备中安装时,核心位置永远不会请求用户权限。 当我尝试获取button单击位置时,我得到kCLAuthorizationStatusNotDetermined作为authorisationStatus。 请帮助我。 我不知道发生了什么事。 – (IBAction)fetchLessAccurateLocation:(id)sender { [self.txtLocation setText:@""]; locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyKilometer; locationManager.distanceFilter = 1000; if ([self shouldFetchUserLocation]) { [locationManager startUpdatingLocation]; } } 这是我的shouldFetchUserLocation方法: -(BOOL)shouldFetchUserLocation{ BOOL shouldFetchLocation= NO; if ([CLLocationManager locationServicesEnabled]) { switch ([CLLocationManager authorizationStatus]) { case kCLAuthorizationStatusAuthorized: shouldFetchLocation= YES; break; case kCLAuthorizationStatusDenied: { […]

如何获得位置用户的CLLocationManager在迅速?

我有我的视图控制器上的这段代码,但这不工作: import UIKit import CoreLocation class ViewController: UIViewController, CLLocationManagerDelegate { var location: CLLocationManager! override func viewDidLoad() { super.viewDidLoad() location=CLLocationManager() location.delegate = self location.desiredAccuracy=kCLLocationAccuracyBest location.startUpdatingLocation() } func locationManager(location:CLLocationManager, didUpdateLocations locations:AnyObject[]) { println("locations = \(locations)") label1.text = "success" } 我有我阅读其他职位的权限。 但我从来没有获得,没有println .. 谢谢!!

iPhone GPS在后台暂停后不会恢复

我的应用程序需要跟踪用户在后台的位置变化,只要用户移动,就可以正常工作。 当用户停止并且CLLocationManager在10-20分钟左右之后暂停时。 这是通知: -(void)locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager{} 这对我也很好。 太好了,我省了一些电池等等 问题是,当用户开始再次移动时, CLLocationManager永远不会被唤醒, 直到我将应用程序放到前台 (获取活动状态) 之前 ,下面的委托方法才会被触发 : //Never called back after CLLocationManager pauses: -(void)locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager{} -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{} 为什么在设备重新开始移动之后, locationManagerDidResumeLocationUpdates从来不会被调用? GPS不应该自动恢复(自动暂停)? 有没有用户的交互恢复GPS的方法? 应用程序在Info.plist文件中声明如下: 我的CLLocationManager设置是: locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; [locationManager setActivityType:CLActivityTypeFitness]; //I WANT pauses to save some battery, etc… That is why following line […]

iOS Geofence CLCircularRegion监控。 locationManager:didExitRegion似乎没有按预期工作

我目前正试图让我的应用程序使用CoreLocation来监视特定的区域,但是我发现它似乎并不像预期的那样工作,在我看来,它不能为每个位置(即10米)设置一个小的半径集。 我也放了一个小testing应用程序,在地图上绘制圆半径 ,以便我可以直观地看到发生了什么。 我用于监视位置的代码如下所示: self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; // Set-up a region CLLocationDegrees latitude = 52.64915; CLLocationDegrees longitude = -1.1506367; CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(latitude, longitude); CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:centerCoordinate radius:10 // Metres identifier:@"testLocation"]; [self.locationManager startMonitoringForRegion:region]; 我还没有把这里的代码放在DidEnter地区等,因为我知道,当我离开监控区域超过100米的时候,这个代码是有效的。 这里是一个应用程序的屏幕截图,当我远离地图上的紫色位置超过10米时,出口区域事件不会触发,但是如果我将位置切换到伦敦,它会触发,而且当我设置我的位置时回到当前蓝色位置的地方也会发生火灾。 有谁知道是否有最小区域半径的限制,或者我可能做错了什么。 谢谢Aaron

didFailWithError:错误域= kCLErrorDomain代码= 0“操作无法完成。 (kCLErrorDomain错误0.)“

我想获得当前的位置,但是我得到一个错误。 这是我的视图控制器的一个片段。 – (void)viewDidLoad { self.locationManager = [[CLLocationManager alloc] init]; [locationManager setDelegate:self]; [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters]; [locationManager startUpdatingLocation]; } – (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations { // I would get the latest location here // but this method never gets called } – (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { NSLog(@"didFailWithError: %@", error); } 我期待的委托方法locationManager:didUpdateLocations:得到调用,而是,只有locationManager:didFailWithError:被调用,并打印这个: didFailWithError: Error Domain=kCLErrorDomain Code=0 […]