LocationManager(_:didupdatelecations :)上次输入有时极其过时

发布于 2025-01-28 20:26:37 字数 398 浏览 3 评论 0原文

根据苹果的

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

望喜 2025-02-04 20:26:37

当位置服务无法通过请求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.

It will return the cached/recent location.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文