iphone:随机调用 CLLocation deletgate 方法
我正在使用 CLLocationManager
来获取位置。虽然我的设备上有 GPS 设置
,但它会随机显示在 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";
}
}
I am using CLLocationManager
to grab the location.Though I have GPS settings working on my device
, it shows the status popup randomly which is defined in didFailWithError
Error I am getting is,
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";
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需找出错误是什么
其他错误代码
Just find out whats the error
other error codes