距离传感器的使用

- (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(@"有物体远离设备屏幕"); } }

 

posted on 2015-11-06 10:57  骑蜗牛溜溜弯  阅读(234)  评论(0编辑  收藏  举报

导航