There appears to be a previously documented (and reported) bug in iOS (which still, it appears to exist in 'the latest iOS') which means that while you can use [[UIScreen mainScreen] setBrightness:x] once the Application has started you can not call it at any time during the backgrounding event (which means you can't RESTORE brightness to the level it was at before your app started).
// Works as expected, screen dims
- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSLog(@"applicationDidBecomeActive");
// Dim the screen (works)
[[UIScreen mainScreen] setBrightness:0.2];
}
But...
// Seems to fire if you double-tap the home key ('task manager' ;)
// Doesn't work
- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(@"applicationWillResignActive");
[[UIScreen mainScreen] setBrightness:1.0];
}
The background to this is I'm porting my successful Dock Clock app from Android to iOS and have now discovered that I can not restore screen brightness. It's obviously a bug but I wondered if anyone has discovered a work-around?
Here's a very simple prototype test app which proves the bug: