0

我无法在设备上获取当前位置。它首先正确显示了几次,但第三次失败并显示以下消息:

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)

请帮忙。提前致谢。

4

3 回答 3

0

这种错误(操作无法完成。(kCLErrorDomain错误0。))可能是由于很多原因造成的。

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

位置管理器错误:(KCLErrorDomain 错误 0) didFailWithError:错误域 = kCLErrorDomain 代码 = 0“操作无法完成。(kCLErrorDomain 错误 0。)”

于 2013-07-02T13:26:55.627 回答
0

来自 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.
于 2013-07-02T13:27:58.147 回答
0

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

于 2015-07-27T08:45:21.783 回答