Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想做的只是让iDevice将屏幕淡化为黑色,proximityState返回yes。但是,我不确定如何启用它或监视它。有人可以简单地提供启用和监视proximityState 的语法吗?对于像我这样的新程序员,我们将不胜感激。
谢谢!-杰克
您需要使用[UIDevice currentDevice]单例。首先设置proximityMonitoringEnabled为YES. 然后,您可以通过该proximityState属性访问邻近信息。UIDeviceProximityStateDidChangeNotification通过观察通知来订阅对邻近状态的更改。
[UIDevice currentDevice]
proximityMonitoringEnabled
YES
proximityState
UIDeviceProximityStateDidChangeNotification