我无法在设备上获取当前位置。它首先正确显示了几次,但第三次失败并显示以下消息:
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)
请帮忙。提前致谢。