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

查看:164
本文介绍了屏幕锁定时启用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天全站免登陆