Created
May 25, 2012 06:13
-
-
Save donly/2786100 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 添加通知 | |
[[UIDevice currentDevice] setProximityMonitoringEnabled:YES]; | |
if ([UIDevice currentDevice].proximityMonitoringEnabled == YES) | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(proximitySensorChange:) | |
name:UIDeviceProximityStateDidChangeNotification | |
object:nil]; | |
// 移除通知 | |
if ([UIDevice currentDevice].proximityMonitoringEnabled == YES) | |
[[NSNotificationCenter defaultCenter] removeObserver:self | |
name:UIDeviceProximityStateDidChangeNotification | |
object:nil]; | |
[[UIDevice currentDevice] setProximityMonitoringEnabled:NO]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment