didFailWithError: Error Domain=kCLErrorDomain Code=0 "操作无法完成.(kCLErrorDomain 错误 0.)" [英] didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

查看:32
本文介绍了didFailWithError: Error Domain=kCLErrorDomain Code=0 "操作无法完成.(kCLErrorDomain 错误 0.)"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取当前位置,但出现错误.

I want to get the current location, but instead I get an error.

这是我的视图控制器的片段.

This is a snippet of my view controller.

- (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: 被调用,并打印:

I'm expecting the delegate method locationManager:didUpdateLocations: to get called, but instead, only locationManager:didFailWithError: gets called, and prints this:

didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)" 

推荐答案

  1. 检查您是否确实拥有有效的 WiFi 和 3G 连接

  1. Check that you actually have a valid WiFi and 3G connection

...如果你这样做,那么:

...if you do, then:

转到设置并重置您的位置服务

Go to settings and reset your location services

这应该解决这个问题.它与设备/网络相关,与应用程序无关.这很烦人,尤其是如果您的应用依赖于位置服务并且设备仅支持 WiFi 并且人们在 AppStore 上给出负面评价...请原谅我,我在那里有点情绪化.

This should take care of that issue. It is device/network related not app related. It's annoying especially if your app is dependent on location services and the device is WiFi only and people give negative ratings on the AppStore... Pardon me, I'm getting a bit emotional there.

这篇关于didFailWithError: Error Domain=kCLErrorDomain Code=0 &quot;操作无法完成.(kCLErrorDomain 错误 0.)"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆