-2

Before iphone lock the screen, it will dim the screen first for a while. I wonder how to lighten the screen in my app at that time without touching the screen. Can anyone give a help?

To be more specific: I don't want to prevent the system sleep, nor adjust the screen brightness. What I want is to lighten the screen when I got a certain event to notice the user while the screen is dimmed.

Just solve this problem in a tricky way..

- (void)lightenTheScreen
{    
    [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
}
fantaxy
  • 221
  • 2
  • 8

1 Answers1

2

That is default behavior of the iPhone. To prevent that nature you can use following code.

[[UIApplication sharedApplication] setIdleTimerDisabled: YES]; //Add this at the end in your applicationDidFinishLaunching application

From APPLE DOCUMENTATION

"The default value of this property is NO. When most applications have no touches as user input for a short period, the system puts the device into a "sleep” state where the screen dims. This is done for the purposes of conserving power. However, applications that don't have user input except for the accelerometer—games, for instance—can, by setting this property to YES, disable the “idle timer” to avert system sleep. "

Janak Nirmal
  • 22,706
  • 18
  • 63
  • 99
  • Hi Jennis, thanks for your answer. But I think you misunderstood my question. I don't want to prevent the system sleep. What I want is to lighten the screen when I got some event to notice the user while the screen is dimmed. – fantaxy Apr 10 '13 at 06:46