在屏幕锁定时启用 iPhone 加速度计 [英] Enable iPhone accelerometer while screen is locked

查看:28
本文介绍了在屏幕锁定时启用 iPhone 加速度计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,显然可以在屏幕锁定时让处理器继续处理内容,如下所示:

So apparently it is possible to keep the processor going processing stuff while the screen is locked, as indicated here:

在睡眠模式下运行 iPhone 应用

但是,在使用示例代码进行测试后,UIAccelerometer 将在设备立即锁定后立即停止提供值.有没有办法强制?

However, after testing with the example code, UIAccelerometer will just stop giving value as soon as the device is locked pronto. Is there a way to force otherwise?

推荐答案

在 3.1.2 之前的 iPhone OS 中存在一个错误,该错误会导致加速度计在屏幕空白时立即停止返回值.您可能会遇到同样的问题.我向 Apple 提交了一个关于它的错误,他们在 3.1.2 中修复了它.

There was a bug in iPhone OS prior to 3.1.2 that caused the accelerometer to stop returning values as soon as the screen was blanked. You may be running into this same issue. I filed a bug with Apple about it and they fixed it in 3.1.2.

我在应用中使用的一个技巧是启用接近传感器.这允许我的应用程序继续运行,但如果用户将手机放在口袋里或以其他方式绊倒传感器,屏幕将关闭并且不消耗电量.同时,我的应用仍在运行,并且(3.1.2 或更高版本)加速度计继续发送更新.

One trick I use in an app is to enable the proximity sensor. This allows my app to continue running, but if the user puts their phone in their pocket or otherwise trips the sensor, the screen turns off and doesn't consume power. Meanwhile, my app is still running and (3.1.2 or later) the accelerometer continues sending updates.

这篇关于在屏幕锁定时启用 iPhone 加速度计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆