Keep display on when the proximity sensor is covered

后端 未结 5 1023
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 12:39

I want to intercept the proximity sensor without turning off the display.

I know by the documentation that I have two Bool variables:

proximityMonitoring         


        
5条回答
  •  野的像风
    2021-02-05 13:38

    Use the following API to enable/disable the proximity sensor.

    [UIDevice currentDevice].proximityMonitoringEnabled = NO; // Disables the Proximity Sensor and won't turnoff the display when sensor covered
    
    [UIDevice currentDevice].proximityMonitoringEnabled = YES; // Enables the Proximity Sensor and will turnoff the display when sensor covered
    

    Not all iOS devices have proximity sensors. To determine if proximity monitoring is available, attempt to enable it. If the value of the proximityMonitoringEnabled property remains NO, proximity monitoring is not available.

提交回复
热议问题