【发布时间】:2017-01-22 00:42:01
【问题描述】:
我收到此错误:
更新位置时出错操作无法完成。 (kCLErrorDomain 错误 0。)
我的问题是,几乎每次我运行模拟器时都会显示此错误,并且在模拟器运行的整个过程中都会一直显示该错误(每次我向 viewController 提供地图时,它都会显示此错误)。最奇怪的是有时这个错误为零,一切都很好。在实际设备上它可以正常工作,但是当我想尝试使用位置(在模拟器上)时,我必须重新启动模拟器大约 7 次才能正常工作。
这是 Info.plist:
我的位置是自定义的:
这是我的代码:
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
print("Error while updating location " + error.localizedDescription)
let alertController = UIAlertController(title: "Sorry!", message: "We were unable to find your location", preferredStyle: UIAlertControllerStyle.Alert)
let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
alertController.addAction(defaultAction)
presentViewController(alertController, animated: true, completion: nil)
print("Error...")
}
我的问题是为什么它只有时有效? 谢谢你:)
【问题讨论】:
-
您可以查看此链接。 stackoverflow.com/questions/6032976/…
-
我已经看到了这个问题,但我找不到解决方案:/
-
然后选择模拟器菜单>调试>位置>设置自定义或选择任何0r检查互联网连接
-
我的互联网连接应该没问题(我坐在距离路由器 2 米的地方,而且互联网速度很快)。
标签: ios swift xcode cllocationmanager