UIScreen Brightness Property

自古美人都是妖i 提交于 2019-11-28 07:44:05

问题


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?


回答1:


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.




回答2:


It sets the brightness for the device on iPad, and iPhone, just like in the Settings. It changes the brightness even when the app closes, it is kind of annoying. You have to reset it back to default programmatically in the appropriate method. I just created a tracing table app, Lite Box, and noticed it does not go back to the initial setting, even when app is force closed. You have to reopen app....set back to default, or go to your Settings and change it back.



来源:https://stackoverflow.com/questions/7900895/uiscreen-brightness-property

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