距离传感器的使用
- (void)ViewDidLoad { // 打开距离传感器,开启距离检测功能 [UIDevice currentDevice].proximityMonitoringEnabled = YES;
// 监听距离改变 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proximityStateDidChange:) name:UIDeviceProximityStateDidChangeNotification object:nil]; } - (void)proximityStateDidChange:(NSNotification *)note { if ([UIDevice currentDevice].proximityState) { NSLog(@"有物体靠近设备屏幕"); } else { NSLog(@"有物体远离设备屏幕"); } }
我们不必羡慕他人,
因为每个人都有自己最美丽的玫瑰,也都有自己要征服的狐狸。
------做一个幸福的人