问题描述
目前我正在尝试创建一个应用程序来调整设备的亮度。在iOS5中,mainScreen有一个新的亮度属性,允许您设置屏幕亮度。我正在使用以下代码:
At the moment I'm trying to create an application to adjust the device's brightness. In iOS5, there is the new brightness property for mainScreen that allows you to set the screen brightness. I'm using the following code:
[[UIScreen mainScreen] setBrightness:1.0];
然而,这似乎只有在设备被锁定后才能工作,并且不会保存在设置中。有什么我做错了吗?
However this seems to only work until the device is locked, and doesn't get saved in settings. Is there something I'm doing wrong?
推荐答案
您需要在<$中保存自己想要设置的值c $ c> NSUserDefaults 并在您的应用程序委托的恢复亮度的方法。
You will need to save the value you want to set yourself in your NSUserDefaults
and call setBrightness:
in your application delegate's applicationDidBecomeActive:
method to restore the brightness.
这篇关于UIScreen亮度属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!