views:

38

answers:

1

I have an app with some animations which are called by timers. When one animation finishes then a timer is called to start another. If the iPhone sleeps and requires unlocking to activate it then the animations do not start. This is obviously because the timer ends whilst the app is asleep and then the function to restart an animation doesn't get called.

What I want to do is check if the animations are running and if not activate them - or maybe stop them when the app sleeps and activate them when it starts again.

I have been trying to find a method to do this but after hours of googling I can't find anything - it is completely possible I'm not searching for the right thing!

Any suggestions would be greatly appreciated?

Also is there a way of forcing the iPhone to sleep when connected to XCode?

THANKS

+2  A: 

When the iPhone screen locks the notification UIApplicationWillResignActiveNotification is sent. After the screen is unlocked the notification UIApplicationDidBecomeActiveNotification is sent. You have two choices:

  1. You can register with NSNotificationManager to get UIApplicationDidBecomeActiveNotification notification and restart your timers after wakeup if they are invalidated.

  2. You can implement applicationDidBecomeActive in your app delegate and restart your timers there if they are invalidated.

progrmr