4

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:

https://github.com/philask/Dockclock-iOS

philask
  • 790
  • 9
  • 12

1 Answers1

1

I didn't try to restore it when my app enter the background .. but I notice that it will be restored when you lock and unlock the device.

Malek_Jundi
  • 6,140
  • 2
  • 27
  • 36
  • 1
    Deeper diving in the Apple developer forums shows this is clearly a bug. Intention is that the app can use setBrightness however it likes and the OS will deal with restoring brightness on switch / background (as Android does). So it's a bug, and I've logged a bug report with Apple (although I understand so have a few hundred other developers). – philask Jun 14 '12 at 09:50
  • So is there a way to restore brightness at the end of an application or when it goes to background ?? – Fredv Jan 25 '13 at 10:28
  • Can confirm this for IOS 6.1.4 – tmanthey Jun 01 '13 at 10:56