【发布时间】:2011-10-20 13:54:08
【问题描述】:
我正在使用CLLocationManager 来获取位置。虽然I have GPS settings working on my device,它会随机显示在didFailWithError 中定义的状态弹出窗口
我得到的错误是,
Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
-(void) startGettingCurrentLocation {
CLLocationManager *locationManager=[[CLLocationManager alloc] init];
locationManager.delegate=self;
locationManager.desiredAccuracy=kCLLocationAccuracyNearestTenMeters;
[locationManager startUpdatingLocation];
}
- (void) locationManager:(CLLocationManager *) manager didFailWithError:(NSError *)error {
[locatingAlert dismissWithClickedButtonIndex:0 animated:NO];
UIAlertView *statusAlert;
statusAlert = [[UIAlertView alloc] initWithTitle:@"" message:@"In order to use this application properly, you need to allow use of the GPS." delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
[statusAlert addButtonWithTitle:@"OK"];
[statusAlert show];
//Set Default Coordinates it app not able to get location
if (mainDelegate.currentLatitude == nil) {
mainDelegate.currentLatitude = @"28.6317021";
}
if (mainDelegate.currentLongitude == nil) {
mainDelegate.currentLongitude = @"-81.423110";
}
}
【问题讨论】:
-
你怎么称呼那个代表?
-
我问你是否将 cllocationmanager.delegate=self 放在 viewdidload 中?
-
为什么每次都更新时要显示警报?相反,您可以删除警报吗?
-
已编辑问题,请查看
标签: iphone objective-c cllocationmanager