• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting brightness and applicationWillResignActive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting brightness and applicationWillResignActive


  • Subject: Re: Setting brightness and applicationWillResignActive
  • From: David Duncan <email@hidden>
  • Date: Mon, 23 Jun 2014 09:25:15 -0700

On Jun 22, 2014, at 8:50 PM, Jim Geist <email@hidden> wrote:

> My iOS application needs to keep the device active by disabling the idle timer, but dims the display to conserve battery since it will be running for long periods. This works fine, but I want to make sure to restore the user’s settings if the app is switched away from.
>
> The code sets [UIScreen mainScreen].brightness back to the original settings in a handler for UIApplicationWillResignActiveNotification. However, setting the brightness here is ignored (as is doing it in the applicationWillResignActive: handler in the application delegate).

Actually, the setting is explicitly ignored at this time to avoid large surprising brightness changes. If I remember correctly, the brightness change will be applied the next time the screen cycles between off and on if your application is not frontmost.

The system will also normally do this for you without needing to reset it during willResignActive.

> I think the problem is that by the time the notification is sent, the application is already past the point where it owns the screen (a breakpoint on the handler doesn’t fire until after the app is off the screen). applicationDidEnterBackground: doesn’t work, either.
>
> StackOverflow, in previous threads on this, suggests rendering an alpha’ed black rectangle over the app, but that’s not really useful when the intent is to save battery life.
>
> Anyone have any ideas?
>
> Thanks!!
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

--
David Duncan


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Setting brightness and applicationWillResignActive (From: Jim Geist <email@hidden>)

  • Prev by Date: Setting brightness and applicationWillResignActive
  • Next by Date: NSWindowController and designated initializer rules
  • Previous by thread: Setting brightness and applicationWillResignActive
  • Next by thread: NSWindowController and designated initializer rules
  • Index(es):
    • Date
    • Thread