我有一个问题SignificantLocationChanges
自iOS 8发布以来。该方法
[locationManager startMonitoringSignificantLocationChanges];
在检查可用性后被正确调用,代表也工作得很好(我用didChangeAuthorizationStatus
方法,它是同一个委托和对象的一部分),编译器毫无疑问,但绝对没有更新,也没有错误didFailWithError
方法。日志说授权状态是4,我认为还可以。
在 iOS 8 之前,这一切都工作正常。
第一个测试设备(带 3G 的 iPad 2)运行 iOS 7.1.2,第二个测试设备(iPhone 5)运行 8.0.2,当我使用正常模式时startUpdatingLocation
方法我立即得到更新。但SignificantLocationChanges
对我的工作会好很多。有谁知道错误可能出在哪里?
在 iOS 8 中,您必须请求类型为“始终”的授权,以允许您的应用程序使用重要位置。
Add a new row in your -Info.plist file with key NSLocationAlwaysUsageDescription
如果尚未请求,则请求授权。
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
if (status == kCLAuthorizationStatusNotDetermined && [manager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[manager requestAlwaysAuthorization];
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)