关闭 iPhone 操作系统 (iOS) 中的显示
有没有办法以编程方式关闭 iOS 中的显示?不仅仅是降低亮度,而是像电话应用程序那样关闭。我很高兴使用私有 API,因为这是供个人使用的。
谢谢!
is there a way to programmatically turn off the display in iOS? Not just turning brightness down, but off like the way the Phone App does. I am happy to use private API, since this is for personal use.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以通过启用近距离监控来关闭显示。它将自动关闭屏幕,就像在“电话”应用程序中一样,只需将手机放在耳朵附近或将手指放在手机顶部的红外传感器上即可。
You can turn off the display by enabling the proximity monitoring. It will automatically turn off the screen, like in the Phone app, by placing the phone near your ears or by placing a finger over the IR sensor at the top of the phone.
您可以这样做(当然,使用私有 API):
在 iOS5 上:
然后
在您想要调暗或
取消调暗时使用。
在iOS6上:
然后使用:
“Dim”这里的意思是完全关闭屏幕。这是系统在通话过程中发生接近事件等情况时使用的方法。
You can do this, (obviously, using Private APIs of course) :
on iOS5:
and then use
whenever you want to dim, and
whenever you want to undim.
On iOS6:
and then use:
"Dim" here means totally turn off the screen. This is what the system uses when e.g. a proximity event occurs while in a call.
我知道的唯一方法,无论是公共的还是私人的,都是使用电源按钮。
您可以查看
-[UIApplication setProximitySensingEnabled:(BOOL)]
或-[UIApplication setIdleTimerDisabled:YES]
,这可能会带来一些有用的结果The only way I know of, public or private, is using the power button.
You might look at
-[UIApplication setProximitySensingEnabled:(BOOL)]
, or-[UIApplication setIdleTimerDisabled:YES]
, this might lead to something useful您是否尝试过:
[[UIScreen mainScreen] setBrightness: yourvalue];
所以问题8936999:iPhone:我们如何以编程方式更改屏幕的亮度?
Have you tried:
[[UIScreen mainScreen] setBrightness: yourvalue];
SO question 8936999: iPhone: How can we programmatically change the brightness of the screen?
邻近功能并不适用于所有设备。对于这个问题,有一个更简单的解决方案,无需求助于私有 API。
Swift
如果没有
wantsSoftwareDimming
,背光将永远不会完全关闭。该文档有这样的警告句子:
Proximity doesn't work on all devices. There's a much simpler solution to this problem without resorting to private APIs.
Swift
Without
wantsSoftwareDimming
, the backlight will never completely turn off.The docs have this cautionary sentence:
我认为除了改变亮度之外,没有任何方法可以关闭显示器(模拟iPhone睡眠按钮)。
此链接可能会有所帮助。
I do not think there is any to turn off the display (simulating iphone sleep button) except changing the brightness.
This link might help.