Why can't I set screen brightness in applicationDidEnterBackground or applicationWillResignActive?
This is my code:
-(void)applicationDidEnterBackground:(UIApplication *)application {
[[UIScreen mainScreen] setBrightness:1.0];
}
Can't understand it...!? It works in applicationDidEnterForeground
etc, just not when i close the app using the home button.
Is there any other solution to this problem?
Update August 2016:
Brightness changes made by an app remain in effect until the device is locked, regardless of whether the app is closed. The system brightness (which the user can set in Settings or Control Center) is restored the next time the display is turned on.
https://developer.apple.com/reference/uikit/uiscreen/1617830-brightness
Original Post July 2012:
You're not allowed to set the brightness just before exiting. This is not documented anywhere but the following post on the dev forums is helpful:
https://devforums.apple.com/thread/139813?start=0&tstart=0
What should happen is the system-wide brightness is restored when the app is backgrounded. There is a known bug where this doesn't actually happen until the next time the backlight is switched off and on.
You can reproduce this easily by setting the brightness to 0 and pressing the home key. The home screen will still be very dark. Lock then unlock your device and the system brightness is restored.
Please file a bug about this! On the same post an Apple employee posted that repeated bug reports are helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With