测试iphone屏幕是否打开/关闭
我正在开发一个应用程序来测试 iPhone 屏幕是关闭还是打开,我尝试了堆栈溢出中指定的加速度计代码,它对于屏幕状态运行良好,但当我关闭屏幕时,加速度计不会停用。
所以我对屏幕关闭时加速度计是否真的自动停用这一事实感到怀疑。如果有人对此有明确的想法,请分享。
谢谢
I am developing a application to test whether the iphone screen is OFF or ON and i tried the code of accelerometer that specified in stack overflow it working well for screen on status but when i turn off the screen the accelerometer is not deactivating.
So i am getting doubt about the fact that did really accelerometer get deactivate automatically when the screen turns off. If anybody having clear idea about it please share it.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应用程序在睡眠时暂停。您应该为其实现一个后台任务。
https://developer.apple.com/library/ios/DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW20
Application are paused when it sleep. You should realize a background task for it.
https://developer.apple.com/library/ios/DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW20