Thanatos
Thanatos

Reputation: 113

UIViewController's viewDidAppear/viewDidDisappear: when exactly are that methods supposed to be called?

I definitely need some clarification on when exactly viewDidAppear/viewDidDisappear methods are supposed to be called...

  1. If the application enters background while showing some view, in this case I would expect viewDidDisappear to be called on the UIViewController linked to that view. On the other hand, if the application enters foreground after being background, I would expect viewDidAppear to be called. But it doesn't work this way.
  2. If an UINavigationController displays an UIViewController we call 'A', and that UIViewController is linked to a view that has a subview linked to another UIViewController we call 'B', the viewDidAppear method is NOT called on the controller 'B'. Do I have to propagate viewDidAppear myself? I'm confused...

Thank you in advance!

Upvotes: 1

Views: 4016

Answers (2)

bijan
bijan

Reputation: 1685

There is also:

(also an app delegate method):

- (void)applicationDidEnterBackground:(UIApplication *)application

Upvotes: 0

Krumelur
Krumelur

Reputation: 33048

  1. They are not called because they don't disappear and reappear unless you tell them to disappear. Your whole application is suspended. You need to listen to the app delegates applicationDidBecomeActive: and applicationWillResignActive: messages if you want to know if your app got suspended or gets reactivated. You can also register for the notifications UIApplicationDidBecomeActiveNotification and UIApplicationWillResignActiveNotification.

  2. Yes, you have to propagate the viewDidAppear: messages to your subviews manually. This is working as designed.

Upvotes: 3

Related Questions