如何在 iPhone 上可靠地获取位置

发布于 2024-08-19 17:35:47 字数 318 浏览 3 评论 0原文

我正在开发一个使用 iPhone GPS 来获取位置轨迹的应用程序。为了节省电量,我想在屏幕关闭时获取位置数据。我已经学会了播放无声音频文件以在睡眠模式下保持位置获取的技巧。我仍然偶尔会遇到位置获取在睡眠模式下停止的问题。这种情况发生的概率可能是 5 - 10%。我怀疑我可能没有足够好的位置修复来开始,尽管地图视图上当前位置注释的外观似乎意味着良好且准确的修复。有谁知道有什么好方法可以明确确定位置经理有一个好的解决方案吗?有谁知道在睡眠模式下“踢”位置管理器以使其继续运行的任何技巧吗?我尝试运行一个 30 秒的重复计时器并在每次触发时读取当前位置。可悲的是,这没有帮助。任何建议表示赞赏。

-富有的

I'm working on an application that uses the iPhone GPS to acquire a location track. To save power, I want to acquire location data while the screen is off. I've learned the trick of playing a silent audio file to keep the location acquisition going while in sleep mode. I still have an occasional problem with location acquisition stopping in sleep mode. This happens maybe 5 - 10% of the time. I suspect that I may not have a good enough location fix to start with, although the appearance of the current location annotation on the map view seems to imply a good and accurate fix. Does anyone know a good way to determine definitively that the location manager has a good fix? Does anyone know any tricks for "kicking" the location manager while in sleep mode to keep it going? I tried running a 30 second repeating timer and reading the current location each time it fired. Sadly, this didn't help. Any suggestions are appreciated.

-rich

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

逆流 2024-08-26 17:35:47

您可以检查位置管理器返回的数据的horizo​​ntalAccuracy 属性,以查看位置是否足够准确。

关闭显示器并节省电池电量的另一种无需技巧的方法是启用接近传感器并禁用睡眠。这样,当手机放在口袋中时,显示屏会变黑,而当您拿起手机查看时,显示屏会亮起。

You can check the returned data from the location manager for the horizontalAccuracy property, to see if the location is accurate enough or not.

Another way to turn off the display and save battery power without tricks is to enable the proximity sensor, and disable sleep. That way the display will blank when the phone is in your pocket, and light up when you pick it up to look at it.

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