iOS 9 - 位置更新获取错误didFailWithError:错误域= kCLErrorDomain代码= 0“(null)”

时间:2015-08-06 12:25:28

标签: objective-c ios8 cllocationmanager ios9

我使用以下代码更新位置 - 它在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文件 -

中进行了更改

enter image description here

任何人都可以建议我缺少什么?

3 个答案:

答案 0 :(得分:2)

当位置要求键未添加到Info.plist时,此错误也在上升。

检查Info.plist中是否有其中一个密钥(包含Bool值):

NSLocationWhenInUseUsageDescription 
NSLocationAlwaysUsageDescription

答案 1 :(得分:0)

  • 请重置您的网络设置
  • 重置您的位置服务
  • 检查WiFi或3G是否正常工作
  • 另一个是当Scheme / Edit Scheme / Options / Allow Location Simulation选中但没有设置默认位置时。

答案 2 :(得分:0)

根据@Pasha_Molodkin的建议,我建议你试试这个(当没有提供默认位置时常见的错误):

my answer to a similar post

简而言之:

  • 产品 - >方案 - >编辑方案 - >选项 - >必须选中允许位置模拟并尝试提供默认位置,不要将其设置为" none"