防止iOS接近传感器将屏幕变黑 [英] Prevent the iOS proximity sensor from turning the screen black

查看:113
本文介绍了防止iOS接近传感器将屏幕变黑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过几次这个问题,但是没有人回答-实际上这是不可能的,但是我想知道是否有一种方法可以防止当iPhone上的接近状态改变时屏幕变黑. ?

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

    }

}

推荐答案

遗憾的是,当前的公共API不允许您执行此操作.您可能要通过Apple Bug Reporter提交增强请求: http://developer.apple.com/bugreporter/

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/

这篇关于防止iOS接近传感器将屏幕变黑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆