Take the 2-minute tour ×

Maybe someone could tell me why when launch my app in the second time (after pressing the home button) the method viewDidLoad: is not being called?

share|improve this question
Can we have some code please to illustrate this problem (e.g. with an NSLog(@"viewDidLoad"); in the relevant place which you have tested and made sure does not work as expected? –  jrtc27 Aug 27 '10 at 17:15
add comment

3 Answers

On iOS 4 apps are no longer exited when pressing the home button. They are moved out of RAM, paused and then continued when you re-enter them, not launched again.

share|improve this answer
add comment

In iOS4 there is:

  • (void)applicationDidBecomeActive:(UIApplication *)application { }

Which is called when the application becomes active (out of background) you could call things from here that need to happen when you open the app.

Thanks James

share|improve this answer
There is also - (void)applicationWillEnterForeground:(UIApplication *)application - (void)applicationDidEnterBackground:(UIApplication *)application –  jodm Aug 28 '10 at 22:04
add comment

The second time you "launch" your application, in fact you are not launching but only re-activating (your application was in background). Your views are not reloaded.

As said in the previous answers :

  • You can detect it via (void)applicationDidBecomeActive:(UIApplication *)application and execute some code here (refresh HMI, refetch datas, etc...),
  • Or move your code to viewWillAppear
share|improve this answer
add comment

Your Answer


