UIBackgroundModes 和 UIAccelerometer
我正在开发一个可以在后台运行的导航应用程序。由于将 UIAccelerometer
设置为 location
,因此工作正常。但我也想使用加速度计来获取有关用户正在做什么的一些附加信息。但是,在后台时,UIAccelerometer
不会调用其委托。
有没有办法在后台获取当前加速度?
I'm developing a navigation app which can run in the background. That's working fine thanks to setting UIAccelerometer
to location
. But I'd like to use the accelerometer too, to get some additional information about what the user is doing. However, while in the background, the UIAccelerometer
doesn't call its delegate.
Is there any way to get the current acceleration while being in the background?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我自己找到了解决方案。在后台运行时确实可以获取加速度计数据。我们所要做的就是依赖 CoreMotion 框架,而不是依赖 UIAccelerometer 类,顾名思义,UIAccelerometer 类是一个与用户界面相关的类。
请参阅此问题:iPhone 上的 Nike+ GPS 如何接收加速度计在后台更新?
I found the solution myself. It is indeed possible to get accelerometer data while running in the background. All one has to do is to rely on the CoreMotion framework rather than on the UIAccelerometer class which, as the name suggests, is a user interface related class.
See this question: How Nike+ GPS on iPhone receives accelerometer updates in the background?
不..您将无法在后台获取
UIAccelerometer
值。..您可以获取特定于核心位置
的标题和其他类型的值..NO..you won't be able to get
UIAccelerometer
values in the background..you can get heading and other types of values specific tocore location
though..