LocationManager(_:didupdatelecations :)上次输入有时极其过时
根据苹果的
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
locations.last // this is supposed to be the most recent
}
”请注意,locations.last
有时是过时的几分钟。
abs(locations.last.timestamp.timeIntervalSinceNow) // sometimes very large (e.g. 500, 5000, etc)
有人有任何想法可能导致这个问题吗?
According to Apple's own documentation around CLLocationManager
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
locations.last // this is supposed to be the most recent
}
However, during development, I sometimes notice that locations.last
is sometimes minutes to hours out of date.
abs(locations.last.timestamp.timeIntervalSinceNow) // sometimes very large (e.g. 500, 5000, etc)
Does anyone have any ideas what might be causing this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当位置服务无法通过请求GPS服务器获得当前位置时。
它将返回缓存/最近的位置。这就是为什么您看到它的时间戳为1分钟或1小时前的原因。
如果用户没有显着旅行,这将帮助用户快速访问其当前位置,这就是加速度计来测量设备的运动时。
When Location Service can't get the current location by requesting GPS server.
It will return the cached/recent location. That is why you see its timestamp is 1 min or 1 hour ago.
This will help users to quickly access their current locations if they didn't travel significantly, that is when Accelerometer works to measure the movement of the device.