根据光线感应关闭和开启屏幕
根据光线感应关闭和开启屏幕
UIDevice *_curDevice = [UIDevice currentDevice];
[_curDevice setProximityMonitoringEnabled:YES];
NSNotificationCenter *_defaultCenter = [NSNotificationCenter defaultCenter];
[_defaultCenter addObserverForName:UIDeviceProximityStateDidChangeNotification
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *note) {
if (_curDevice.proximityState == YES) {
NSLog(@"怕是黑屏了吧");
}
else {
NSLog(@"屏幕应该亮了");
}
}];