【发布时间】:2017-01-22 19:07:47
【问题描述】:
CLLocationManager.requestLocation() 需要大约 10 秒来触发 didUpdateLocations 事件。
这里是为CLLocationManager设置的属性
let locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = 10
locationManager.requestWhenInUseAuthorization()
locationManager.requestLocation()
根据documentation,这可能需要几秒钟。
此方法立即返回。调用它会导致位置管理器获取位置修复(可能需要几秒钟)并使用结果调用委托的 locationManager(_:didUpdateLocations:) 方法。
但这可能需要 10 秒吗?还是我错过了什么?
【问题讨论】:
-
(可能需要几秒钟)。确保从主队列更新 UI
-
如果 GPS 尚未运行,则需要一段时间才能获得准确的位置。如果找不到位置,则可能需要超过 10 秒才能放弃。
-
感谢所有 cmets。 @SausageMachine 我没有抱怨,我想知道谷歌地图之类的应用程序如何使用相同的
While using位置访问级别在 3 秒左右获得位置。 @所有天才选民,我问这个是因为我还没有看到一个应用程序花费这么多时间来获取位置。请赐教。
标签: ios swift gps core-location