0
我尝试获取用户当前位置的经度纬度&,我的代码很简单:IOS-didFailWithError:错误域= kCLErrorDomain代码= 0。 (kCLErrorDomain误差为0)”
- (void)viewDidLoad {
self.locationManager=[[CLLocationManager alloc]init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
[locationManager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
float latitude=newLocation.coordinate.latitude;
float longitude=newLocation.coordinate.longitude;
NSLog(@"%f",latitude);
NSLog(@"%f",longitude);
[locationManager stopUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
}
我总是从didFailWithError方法这个错误:
didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
我复位网络,但仍然没有工作。 @derpoliuk –
@ Mr.Bond请在模拟器中检查您的位置调试>位置>当前位置 –
这也不起作用。@ bhavin ramani –