我使用以下代码更新位置 - 它在iOS 9下工作正常,但在iOS 9中得到错误 -
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
[locationManager requestWhenInUseAuthorization];
// tried this also -
/* if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9) {
locationManager.allowsBackgroundLocationUpdates = YES;}*/
[locationManager requestLocation];
didFailWithError:错误域= kCLErrorDomain代码= 0“(null)”
还在plist
文件 -
任何人都可以建议我缺少什么?
答案 0 :(得分:2)
当位置要求键未添加到Info.plist时,此错误也在上升。
检查Info.plist中是否有其中一个密钥(包含Bool值):
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
答案 1 :(得分:0)
答案 2 :(得分:0)
根据@Pasha_Molodkin的建议,我建议你试试这个(当没有提供默认位置时常见的错误):
简而言之: