Tag: cllocation

调用CLLocationManager stopUpdatingLocation后内部GPS天线是否立即停止工作?

这是我的情况。 在我的应用程序中不需要连续监视用户的位置,但我需要的位置尽可能准确。 所以我只是调用CLLocationManager startUpdatingLocation与kCLLocationAccuracyBestForNavigation设置为所需的准确性,并获得我想要的准确性(通过比较newLocation.horizo​​ntalAccuracy与预定义的值)的位置后,我想停止位置更新和撤销更新几秒钟后再次。 但是当我打电话给stopUpdatingLocation状态栏的位置图标大约10秒后消失,这是否意味着苹果已经考虑到这种情况,当用户调用stopUpdatingLocation它不closures天线一段时间,可能是因为把它们回来在能源方面有些贵,所以他们只是等了一段时间,才closures了天线。 或者可能只是简单的位置图标不会消失,但天线closures。 那么有人可以解释什么时候有人调用stopUpdatingLocation?

使用Geocoder更新属性来获取用户实际地址EXC_BAD_ACCESS

我相对是一个新的iOS开发人员,即时通讯处理地理编码器完成处理程序 ,我不明白如何更新地址parsing器的地址find一个variables,并做一些与它的东西。 总之, 我希望geocoder块在某些方法中完成使用信息 。 – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"didUpdateToLocation: %@", newLocation); CLLocation *currentLocation = newLocation; if (currentLocation != nil) { longitudeLabel = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude]; latitudeLabel = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude]; } [locationManager stopUpdatingLocation]; // Reverse Geocoding NSLog(@"Resolving the Address"); __block NSString * **annotation**; [geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) { […]

使用当前位置数据时,CLGeocoder返回城市和州的空结果

嗨,我想获得使用CLGeocoder城市和国家的名称。 但是,placemark.addressDictionary正在返回我: {FormattedAddressLines =(“南大西洋”); 名称=“南大西洋”; 海洋=“南大西洋”; } 并且地标是:南大西洋,南大西洋@ <-42.60533670,-21.93128480> +/- 100.00m,区域CLCircularRegion(标识符:“< – 41.51023865,-31.60774370>半径4958095.65',中心:< – 41.51023865,-31.60774370 >,半径:4958095.65米) 此外,[地标地点]和[地标pipe理区域]的NSLog都显示为零。 还尝试添加ABAdressBookUI,ABAdressBook框架并获取数据为: NSString * addressDict = ABCreateStringWithAddressDictionary(placemark.addressDictionary,NO); 它返回一个空描述的对象。 或者试过:NSString * state =(NSString *)[placemark.addressDictionary objectForKey:kABPersonAddressStateKey]; 它会抛出不兼容指针types的警告。 如果有任何可能的解决scheme或如果我失去了一些东西,请让我知道。 当前位置button被点击时,我的代码如下: CLLocation * loc; loc = [[CLLocation alloc] initWithLatitude:[KLocationManager sharedManager]._locationManager.location.coordinate.latitude longitude:[KLocationManager sharedManager]._locationManager.location.coordinate.longitude]; CLGeocoder* geocoder = [[CLGeocoder alloc] init]; [geocoder reverseGeocodeLocation:loc completionHandler:^(NSArray *placemarks, NSError […]

在iPhone SDK上等待CLLocationManagerDelegate的didUpdateToLocation方法时,UITableView不会填充

我正在尝试用单元格数组填充UITableview。 我通常从viewDidLoad方法做到这一点,但这次我想根据位置填充数组。 以下是我的界面的第一行: @interface RootViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource, CLLocationManagerDelegate> { 在实现文件中,viewDidLoad方法如下所示: – (void)viewDidLoad { // for location self.locationManager = [[CLLocationManager alloc] init]; [locationManager startUpdatingLocation]; locationManager.delegate = self; locationManager.distanceFilter = kCLDistanceFilterNone; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [super viewDidLoad]; } 我在didUpdateToLocation方法中填充单元格数组: self.title = @"Open Buildings"; NSMutableArray *buildingArray = [[NSMutableArray alloc] initWithObjects:building1, self.controllers = array; 视图的标题在find位置时更新,但数组不填充。 在viewdidupdate中有上面的代码之前,数组填充了。 我不得不将它移动到didupdatelocation方法,因为当视图加载到viewDidLoad方法中时,应用程序将没有位置信息。

CLLocationManager保存caching值

CLLocationManager这部分代码用于计算行进距离。 但是即使在使用timeIntervalSinceNow之后,位置caching也不会被删除。 – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { if(newLocation != nil && oldLocation != newLocation) { tempNewLocation = newLocation; tempOldLocation = oldLocation; } NSLog(@"New Location Found"); NSLog(@"- Latitude: %f", newLocation.coordinate.latitude); NSLog(@"- Longitude: %f", newLocation.coordinate.longitude); NSLog(@"- Altitude: %f", newLocation.altitude); NSLog(@"- Course: %f", newLocation.course); NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow]; NSLog(@"The location age %f",locationAge); if (locationAge […]

在ios 6和ios 9之间的CLLocation后台服务启用变化

我有一个在iOS 7上发布的实时应用程序,并使用后台服务。 我正在重新编译ios 9下的应用程序,现在发现应用程序在进入后台时没有收到任何位置更新。 我做了以下更改: 我已经将下面的关键字添加到了我的info.plist文件中,并附带了string值:NSLocationWhenInUseUsageDescription 仍然当应用程序在后台,它停止接收位置更新。 有没有其他的设置或方法,我应该包括哪些将允许应用程序接收位置更新在后台像现场应用程序?

如何从JSON输出中分离纬度和经度值?

我正在尝试两个位置之间的两个绘制路线,为此,我从Google Map API Web服务( JSON输出格式)中获取所有点。 parsingJSON数据和logging点后,我将所有点存储在NSMutableArray 。 每个索引数组都包含这种types的值。 "<+10.90180969, +76.19167328> +/- 0.00m (speed -1.00 mps / course -1.00) @ 12/04/12 10:18:10 AM India Standard Time", 现在我想分离经度和纬度值。 latitude : +10.90180969 longitude : +76.19167328 如何从数组的每个索引获取这个值?

-distanceFromLocation中CLLocation对象的顺序:

这是我第一次在这里发表一个问题,但是我从其他人的问题中find了很多帮助。 我的问题引用了CLLocation的-distanceFromLocation:函数。 我假设findA点和B点之间的距离与B点和A点之间的距离相同,但我发现它不是。 我已经在一个非常简单的情况下testing了这个: CLLocation *test1 = [[CLLocation alloc] initWithLatitude:37.529530 longitude:-122.259232]; CLLocation *test2 = [[CLLocation alloc] initWithLatitude:47.900002 longitude:-103.495102]; NSLog(@"%f vs %f",[test2 distanceFromLocation:test1],[test1 distanceFromLocation:test2]); [test1 release]; [test2 release]; 输出为1907269.942754与1908105.959114,相差近900米。 虽然900米可能是一个小百分比,但我正在试图确定用户是否比注释更接近,而900米可以改变这一点。 我的问题是,这些价值中哪一个是正确的? 此外,如果我testing的位置是重要的,我是否需要总是testing相同的位置(例如用户到目的地和注释到目的地而不是目的地到用户和注释到目的地)? 对不起,这个示例有点偏离了上下文,因为我的项目很大,这说明了我的问题。 任何帮助,将不胜感激,因为这已经使我相当混乱和沮丧。

保存CLLocation错误:发送到不可变对象的变异方法

我已经读了其他相关的问题,但我卡住了。 我正在尝试将最后一个已知位置保存到plist中以备后用。 这是我收到的错误消息: *终止应用程序由于未捕获的exception'NSInternalInconsistencyException',原因:' – [__ NSCFDictionary setObject:forKey:]:mutating方法发送到不可变对象' 这是我的代码: var plist = NSDictionary(contentsOfFile: NSBundle.mainBundle().pathForResource("Config", ofType: "plist")) var dataToStore = NSKeyedArchiver.archivedDataWithRootObject(lastKnownLocation) plist.setValue(dataToStore, forKey: "location") “lastKnownLocation”var是一个CLLocation。 plist中的“位置”键是“数据”types。 有人可以请帮助,让我知道如何做到这一点(或如果有更好的办法他们如何做)? 谢谢

stopRangingBeaconsInRegion可能会停止监视区域的通知?

我正在做一个与CLLocationManager工作的示例项目。 我打电话给startMonitoringForRegion 。 然后,我开始用其他设备模拟一个信标,并didEnterRegion 。 在didEnterRegion ,我调用startRangingBeaconsInRegion并正常工作。 然后,我暂停信标发射器和didExitRegion被调用。 在didExitRegion我调用stopRangingBeaconsInRegion 。 如果我再次启动信标发射器, didEnterRegion不会被调用。 我在Apple文档中find了这个: stopRangingBeaconsInRegion:停止指定信标区域的通知传递。 stopRangingBeaconsInRegion可能会停止监视区域的通知? 我尝试没有stopRangingBeaconsInRegion相同,工作正常。 谢谢 添加更多信息: NSUUID *UUID = [[NSUUID alloc] initWithUUIDString:@"77777777-1717-2727-7777-777777777777"]; NSString *identifier = @"MyBeaconRegion"; CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:UUID identifier:identifier]; [_locationManager startMonitoringForRegion:region]; – (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { NSLog(@"didEnterRegion"); [_locationManager startRangingBeaconsInRegion:(CLBeaconRegion*)region]; NSLog(@"StartRangingBeacons"); } – (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region { NSLog(@"didExitRegion"); […]