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 –