我想獲取當前位置,但我得到一個錯誤。didFailWithError:錯誤域= kCLErrorDomain代碼= 0「操作無法完成。(kCLErrorDomain錯誤0.)」
這是我的視圖控制器的一個片段。
- (void)viewDidLoad {
self.locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray<CLLocation *> *)locations {
// I would get the latest location here
// but this method never gets called
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error {
NSLog(@"didFailWithError: %@", error);
}
我期待的委託方法locationManager:didUpdateLocations:
到被調用,而是,只有locationManager:didFailWithError:
被調用,並打印這樣的:
didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
您可以使用谷歌API作爲替代。請參閱我的答案在這裏http://stackoverflow.com/a/40670608/2033377 – 2016-11-18 06:25:54