ProximityState iPhone 使用
我想做的就是简单地让 iDevice 将屏幕淡入黑色,proximityState 返回 yes。但是,我不确定如何启用它或监视它。有人能够简单地提供启用和监视邻近状态的语法吗? 对于像我这样的新程序员来说,我们将非常感谢您的帮助。
谢谢! -杰克
What I would like to do is simply make the iDevice fade the screen to black one the proximityState returns yes. However, I am not sure of how to enable it, or monitor it. Would someone be able to simply provide syntax of enabling and monitoring proximityState?
The help would be highly appreciated for a new programmer like me.
Thanks!
-Jake
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
[UIDevice currentDevice]
单例。首先将proximityMonitoringEnabled
设置为YES
。然后,您可以通过proximityState
属性访问邻近信息。通过观察UIDeviceProximityStateDidChangeNotification
通知来订阅邻近状态的更改。You need to use the
[UIDevice currentDevice]
singleton. First setproximityMonitoringEnabled
toYES
. Then, you can access the proximity information through theproximityState
property. Subscribe to changes to the proximity state by observing theUIDeviceProximityStateDidChangeNotification
notification.