cdp-snail

距离传感器的使用

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

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-05-03
  • 2021-12-16
  • 2022-02-10
  • 2021-05-16
  • 2021-12-05
  • 2021-07-10
  • 2022-01-14
猜你喜欢
  • 2021-12-20
  • 2021-12-25
  • 2022-02-07
  • 2021-06-18
  • 2021-07-20
  • 2021-08-05
  • 2021-12-05
相关资源
相似解决方案