美文网首页
距离传感器的使用

距离传感器的使用

作者: Areslee | 来源:发表于2016-10-18 16:27 被阅读0次

//开启距离感应功能

[UIDevice currentDevice].proximityMonitoringEnabled = YES;

//监听距离感应的通知

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(proximityChange:) name:UIDeviceProximityStateDidChangeNotification object:nil];

-(void)proximityChange:(NSNotificationCenter*)notification {

if([UIDevicecurrentDevice].proximityState==YES)

{

NSLog(@"某个物体靠近了设备屏幕");//屏幕会自动锁住

}else{

NSLog(@"某个物体远离了设备屏幕");//屏幕会自动解锁

}

}

相关文章

  • iOS 近距离传感器的使用

    使用使用近距离传感器 UIDevice 中有两个近距离传感器的属性:proximityMonitoringEnab...

  • 传感器

    距离传感器的使用 //开启距离感应功能[UIDevicecurrentDevice].proximityMonit...

  • 手把手教你打造智能小车(4)-使用传感器自动避障

    1. 超声波传感器 1.1 简介 超声波传感器是一种广泛使用的距离传感器。本文使用树莓派连接 HC-SR04 超声...

  • iOS 传感器

    目录一、距离传感器二、加速计三、磁力计、陀螺仪的使用和上述加速计的使用步骤类似四、摇一摇五、步数 一、距离传感器 ...

  • 距离传感器的使用

    //开启距离感应功能 [UIDevice currentDevice].proximityMonitoringEn...

  • iOS距离传感器的使用

    // 1开启距离感应功能[UIDevice currentDevice].proximityMonitoringE...

  • iOS - 传感器

    传感器集锦:指纹识别、运动传感器、加速计、环境光感、距离传感器、磁力计、陀螺仪 1,距离传感器 2加速计,哪个方向...

  • iOS距离传感器的简单使用

  • iOS距离传感器的简单使用

    距离传感器主要是检测是否有物品靠近比如:打电话如果贴近耳朵,屏幕自动变暗微信中如果靠近耳朵听语音,屏幕也会自动变暗...

  • 传感器

    一、环境光传感器(Ambient Light Sensor) 二、距离传感器(Proximity Sensor) ...

网友评论

      本文标题:距离传感器的使用

      本文链接:https://www.haomeiwen.com/subject/eirtuttx.html