ViewDidAppear, ViewWillAppear Not Called when returned to Foreground

I have an App that when certain information is pre-entered on the initial screen (view controller 1), I automatically jump modally to a second screen (view controller 2). This is determined in viewdidappear of view controller 1. I has to be in viewdidappear because its at this point that I know the VC1 is in the stack.


This all works fine during an initial lauch of the app. The problem occurs once the app is placed in background and then returns to foreground. The method ViewDidAppear, and all key View methods are not fired (ViewDidLoad, ViewWillAppear, etc). Since this only happens on the initial view controller, this seems to be a flaw in how return to freground processing occurs.


Can someone explain why this works this way and what is a valid solution.


Thanks,

Steve Sykes

This is intended behavior. Bringing the app to the foreground does not trigger a view did appear message.


You can get these application events from your view controller, by using the proper notifications. Check out UIApplication.h:


/
UIKIT_EXTERN NSString *const UIApplicationDidEnterBackgroundNotification       NS_AVAILABLE_IOS(4_0);
UIKIT_EXTERN NSString *const UIApplicationWillEnterForegroundNotification      NS_AVAILABLE_IOS(4_0);
UIKIT_EXTERN NSString *const UIApplicationDidFinishLaunchingNotification;
UIKIT_EXTERN NSString *const UIApplicationDidBecomeActiveNotification;
UIKIT_EXTERN NSString *const UIApplicationWillResignActiveNotification;
UIKIT_EXTERN NSString *const UIApplicationDidReceiveMemoryWarningNotification;
UIKIT_EXTERN NSString *const UIApplicationWillTerminateNotification;
UIKIT_EXTERN NSString *const UIApplicationSignificantTimeChangeNotification;

I have a relatvely simple app that goes to a black screen as it goes from the background to the forgreound. There is no erorr message or anything -- just a black screen. I have to kill the app and launch it again to see the user interface. As there a typical mistake that causes this behavior?

ViewDidAppear, ViewWillAppear Not Called when returned to Foreground
 
 
Q