标签:
根据光线感应关闭和开启屏幕
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(@"屏幕应该亮了");
}
}];
标签:
原文地址:http://www.cnblogs.com/liaolijun/p/4798733.html