Xcode 如何使用延迟位置iOS 6?
我正在尝试使用新的iOS 6功能进行不同的位置更新,但不断出现以下错误: didFinishDeferredUpdatesWithError:Error Domain=kCLErrorDomain Code=11“该操作无法完成。(kCLErrorDomain错误11)。” 我正在使用以下代码:Xcode 如何使用延迟位置iOS 6?,xcode,location,ios6,Xcode,Location,Ios6,我正在尝试使用新的iOS 6功能进行不同的位置更新,但不断出现以下错误: didFinishDeferredUpdatesWithError:Error Domain=kCLErrorDomain Code=11“该操作无法完成。(kCLErrorDomain错误11)。” 我正在使用以下代码: - (DeviceAPI *) init { locationManager = [[CLLocationManager alloc] init]; [locationMan
- (DeviceAPI *) init
{
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
[locationManager allowDeferredLocationUpdatesUntilTraveled:(CLLocationDistance)100000 timeout:(NSTimeInterval)100000];
return self;
}
这个回调
函数:
- (void)locationManager: (CLLocationManager *) manager
didFinishDeferredUpdatesWithError:(NSError *)error
{
NSLog(@"didFinishDeferredUpdatesWithError :%@", [error description]);
}
有什么帮助吗?您是否在info.plist ui backgroundmodes字段中设置了位置?在我的测试中,我发现延迟更新仅在iOS 6.0.1或更高版本中有效,而在iOS 6.0中无效。我在两部手机上进行了测试,一部是我更新的,另一部是我出于测试原因离开6.0的。我相信这就是为什么模拟器不能工作的原因,如果你的手机还没有更新,这也可能是为什么模拟器不能工作的原因 还要确保您实现了 –地点经理:地点更新: 而不是现在被弃用的 –locationManager:didUpdateToLocation:fromLocation:
由于需要与延迟位置更新一起使用。根据iOS 6.0 SDK的Apple开发者论坛,延迟位置更新仅适用于:
- 在iPhone5硬件上
- 运行iOS 6.0或更高版本
- 所需精度设置为导航的
或kCLOCATIONACURACYBEST
,因为这需要一个GPS芯片。没有手机数据的iPad没有GPS芯片李>kCLOCATIONACURACYBEST
- 调用“startUpdatingLocation”方法
- 等待位置更新以大约每秒1次的速度进入
- 然后开始延迟更新
locationManager:didUpdateLocations:
方法
调用此[allowDeferredLocationUpdates
]方法的最常见位置是在代理的
locationManager(uuquot:didUpdateLocations:)
方法。在处理任何
新位置,如果要推迟将来的更新,请调用此方法
直到满足距离或时间标准。如果有新的事件发生
你的应用程序在后台,事件被缓存,其
适当推迟交货
从。我在[]
中添加了注释
我在[CLRegion initCircularRegionWithCenter]调用的一个框架示例中发现了此描述:
“如果覆盖的半径太大,注册会自动失败,因此请将半径钳制为最大值。”在调用AllowDeferredLocationUpdatesUntiltTraveled:timeout之前:将距离过滤器设置为KCLDistanceFilterOne,然后它就会工作。是的,我有。。。我还发现[CLLocationManager deferredLocationUpdatesAvailable]返回FALSE。这在ios6模拟器和iPhone4iOS6设备上都会发生。有什么想法吗?
kclerordomain
的错误11是kclerorderedderedfailed
。请参阅文档。我在寻找iOS 10时发现了这个