appdelegate方法中的setBrightness? [英] setBrightness in appdelegate methods?

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

问题描述

为什么不能在applicationDidEnterBackground或applicationWillResignActive中设置屏幕亮度?

Why can't I set screen brightness in applicationDidEnterBackground or applicationWillResignActive?

这是我的代码:

- (void)applicationDidEnterBackground:(UIApplication *)application
{        
    [[UIScreen mainScreen] setBrightness:1.0]; 
}

无法理解...!?它可以在applicationDidEnterForeground等应用程序中工作,但是当我使用主页按钮关闭该应用程序时不会如此.

Can't understand it...!? It works in applicationDidEnterForeground etc, just not when i close the app using the home button.

感谢任何可以提供帮助的人...

Thanks to anyone that can help...

推荐答案

这可能是因为您的应用将控制权交给了操作系统,然后操作系统将根据用户的全局设置来控制亮度.如果要全局更改亮度设置,则必须访问用户的全局iphone设置并进行更改,但我不确定这是可能的.

It's probably because your app is relinquishing control to the OS, and the OS will then control the brightness according to the user's global settings. If you want to change the brightness setting globally, you'd have to access the user's global iphone settings and change them, and I'm not sure that's possible.

当您在applicationDidEnterForeground上设置亮度时:您的应用再次处于控制状态,并且可以调整亮度之类的内容.一旦您的应用失去了控制思想,操作系统就会接管,并使设备恢复与用户的全局设置兼容.

When you're setting the brightness on applicationDidEnterForeground: your app is in control again, and can adjust stuff like brightness. As soon as your app loses that control thought, the OS takes over and brings the device back into compliance with the user's global settings.

希望有帮助.

这篇关于appdelegate方法中的setBrightness?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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