Prevent the iOS proximity sensor from turning the screen black

旧街凉风 提交于 2020-01-03 17:15:07

问题


I've seen this question asked a couple of times but nobody has answered it - in fact it might be impossible, but I was wondering if there was a way to prevent the screen from going black when the proximityState changes on the iPhone?

I have implemented a method to do something when the proximity state changes, but the screen flickers to black and I want to avoid that. Here is my code:

[nc addObserver:self selector:@selector(proximityChanged:) name:UIDeviceProximityStateDidChangeNotification object:d];

- (void)proximityChanged:(NSNotification *)note {

    if ([[note object] proximityState] == 1) {

        // Do something once the face is close
        // This is where it goes to black


    } else {

        // Do something once the face pulls away

    }

}

回答1:


Sadly, the current public APIs do not allow you to do this. You might want to file an enhancement request via the Apple Bug Reporter: http://developer.apple.com/bugreporter/




回答2:


I would file it with http://radar.apple.com



来源:https://stackoverflow.com/questions/7051794/prevent-the-ios-proximity-sensor-from-turning-the-screen-black

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!