I have an animation based timer app that does not reset when I exit the app. I need to click the home button, then quit the app and re-launch it to get the timer to reset. How do I tell the app to reset when the home button is pushed?
1 Answers
What you are looking for is (source):
- (void)applicationDidBecomeActive:(UIApplication *)application
This method is called to let your application know that it moved from the inactive to active state. This can occur because your application was launched by the user or the system. Applications can also return to the active state if the user chooses to ignore an interruption (such as an incoming phone call or SMS message) that sent the application temporarily to the inactive state.
You should use this method to restart any tasks that were paused (or not yet started) while the application was inactive. For example, you could use it to restart timers or throttle up OpenGL ES frame rates. If your application was previously in the background, you could also use it to refresh your application’s user interface.
OLD ANSWER:
In your UIApplicationDelegate
, there is a delegate method:
[– applicationDidEnterBackground:][2]
which is called when you app enter background. You could stop the timer there.
If you also want that the timer is stopped in the face of other interruptions, like an incoming call, you could use:
applicationWillResignActive

- 68,819
- 11
- 102
- 123
-
thank you for your response. my issues is that even after exiting and re-entering the app, my animations will still be in the same place they were when i hit the home button. on a similar note, i also would like the start button to reset animation. how do i do this? – Riley Shepard Aug 19 '11 at 19:37
-
Please, see my edit. `applicationDidBecomeActive` gives you a chance to do whatever you need whenever your app is awoken from the background... – sergio Aug 19 '11 at 21:31