我有一个CLLocation经理。效果很好。
locManager = CLLocationManager()
locManager.delegate = self
locManager.desiredAccuracy = kCLLocationAccuracyBest
locManager.requestWhenInUseAuthorization()
locManager.startUpdatingLocation()当然,我有委托的方法:
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
println("didfail")
println(error)
}
func locationManager(manager:CLLocationManager, didUpdateLocations locations:[AnyObject]) {
println("location manager called..")
let locationLast = locations.last as! CLLocation
latitude = locationLast.coordinate.latitude.description
longitude = locationLast.coordinate.longitude.description
locManager.stopUpdatingLocation()
//....
}没有任何问题,它是有效的!但是,当我在这里47.5775679,19.0488392 (或在这个点半径1-2公里内)时,它抛出了这个错误:
错误Domain=kCLErrorDomain Code=0“操作无法完成。(kCLErrorDomain错误0。)
我也试过用模拟器和真正的设备。当我尝试的时候,我在真正的设备上有互联网连接。有黑洞吗?:)或者我不知道。
谁能告诉我这个现象的原因是什么?
谢谢!
发布于 2015-05-29 10:50:33
当您的设备无法从实际的GPS系统、wifi或互联网上找到您的位置时,就会发生这种情况。我的观察是,当设备(对于我的情况是iPhone 4)是在一个紧密的房间,并连接到Wifi使用热点从笔记本电脑,那么大多数时候,我是得到同样的错误。
可能的解决方案-
希望这能帮到你。
发布于 2017-06-23 21:26:40
这是一个古老的问题/答案,但它没有考虑模拟器的用例。也就是说,确保您的没有调试> Location > None,如下所示:

例如,一定要选择一个有效的位置,比如苹果在库比蒂诺的总部:

https://stackoverflow.com/questions/30527325
复制相似问题