UIScreen亮度属性 [英] UIScreen Brightness Property

查看:132
本文介绍了UIScreen亮度属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在尝试创建一个应用程序来调整设备的亮度。在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 并在您的应用程序委托的 setBrightness: IOS /文档/ UIKit的/参照/ UIApplicationDelegate_Protocol /参考/#的reference.html // apple_ref / OCC / intfm / UIApplicationDelegate / applicationDidBecomeActive%3A相对= nofollow> applicationDidBecomeActive: 恢复亮度的方法。

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亮度属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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