【问题标题】:Error while getting core location : (null)获取核心位置时出错:(null)
【发布时间】:2013-07-02 13:04:00
【问题描述】:

我无法在设备上获取我的当前位置。它第一次正确显示,但第三次失败并显示此消息:

Error while getting core location : (null)

我的代码是:

CLLocationManager *manager;
manager = [[CLLocationManager alloc] init];
    manager.pausesLocationUpdatesAutomatically=NO;
    manager.delegate = self;//or whatever class you have for managing location
    [manager startUpdatingLocation];

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    NSLog(@"in update location");
}

- (void)locationManager:(CLLocationManager *)manager
       didFailWithError:(NSError *)error
{
    NSLog(@"Error while getting core location : %@",[error localizedFailureReason]);
}

输出是:

2013-07-03 18:32:33.146 CLLocationUpdate[6084:907] in update location
2013-07-03 18:32:33.200 CLLocationUpdate[6084:907] in update location
2013-07-03 18:32:33.517 CLLocationUpdate[6084:907] in update location
2013-07-03 18:32:34.073 CLLocationUpdate[6084:907] in update location
2013-07-03 18:32:50.903 CLLocationUpdate[6084:907] Error while getting core location : (null)

请帮忙。 提前致谢。

【问题讨论】:

  • 你能打印error.localizedDescription吗?
  • 操作无法完成。 (kCLErrorDomain 错误 0。)

标签: iphone ios objective-c core-location cllocationmanager


【解决方案1】:

这种错误(操作无法完成。(kCLErrorDomain error 0.))可能有很多原因。

我找到了几个讨论这个问题的链接,你检查过吗?

Location Manager Error : (KCLErrorDomain error 0) didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

【讨论】:

    【解决方案2】:

    来自 Apple 文档:

    Configuration of your location manager object must always occur on a thread with 
    an active run loop, such as your application’s main thread.
    

    【讨论】:

    • 那我该如何解决这个问题。仅供参考,这在模拟器中运行完美。
    【解决方案3】:

    尝试重置位置服务、Wifi 和网络运营商的设置。有时是由于提供设备位置的资源设置无效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-11
      • 2011-05-21
      • 1970-01-01
      相关资源
      最近更新 更多