views:

37

answers:

1

Hi,

Is there any conventient way of determining if a view is being loaded from the app being in background mode?

In 3.X I would rely on viewDidLoad to do some initalization etc., this however is not the case for 4.X, as you cannot rely for the viewDidLoad method to be called.

I would like to avoid putting in extra flags to detect this in the appdelegate, I would rather use a reliable way of doing this in the UIViewController, but cannot seem to find anything in the lifecycle of a UIViewController that could help me out here.

Any ideas? How do you handle such situations?

+1  A: 
- (void)viewWillAppear:(BOOL)animated

but not

- (void)viewDidLoad

The Application Delegate Method

- (void)applicationWillEnterForeground:(UIApplication *)applicationUIApplicationDelegate

will be called after the the application entered the foreground though you can add an observer for the UIApplicationWillEnterForegroundNotification in any of your views.

Henrik P. Hessel
Yes, I do know viewWillAppear will get called as the name suggests, I cannot base the behaviour on this method, as it will also get called by the framework when views are popped from the stack to show the one we're talking about. Sorry if this wasn't clear from my original post.
Kaspa