ios开发 息屏

[[UIDevice currentDevice] setProximityMonitoringEnabled:YES];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(sensorStateChange:)
name:@"UIDeviceProximityStateDidChangeNotification"
object:nil];

-(void)sensorStateChange:(NSNotificationCenter *)notification;
{
if ([[UIDevice currentDevice] proximityState] == YES) {
NSLog(@"屏幕熄灭");
}else{
NSLog(@"屏幕亮起");
}
}

你可能感兴趣的:(ios开发 息屏)