Does iPhone allow Light sensors as input?

試著忘記壹切 提交于 2019-12-05 09:22:00

An official answer by an Apple rep is on the Apple Dev Forums (login required):

There's no supported way to get at the ambient light sensor. If you'd like to see such support added in the future, I encourage you to file a bug describing your requirements. While we may have seen similar requests many times before, a fresh bug report will allow you to express your needs in your own terms, and allow iOS engineering to gauge the level of demand. http://developer.apple.com/bugreporter

Cᴏʀʏ

Check out this article. There's some code you can download at the bottom. Also, a related question on SO where I found the link.

In the 3.0 SDK the UIDevice class has the proximityState and proximityMonitoringEnabled properties.

BOOL buttonPressed = [UIDevice currentDevice].proximityState;

... gives you the current state.

Keep in mind that the iPod Touch does not have a proximity sensor.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!