adit
adit

Reputation: 33684

when is viewDidAppear called?

If I have a UIViewController called B. If I add UIViewController C as a subview/child view controller of B. Then I add in D as a child view controller of B too. I then remove D from B. In this case should C's viewDidAppear be called afterwards?

The reason I ask is because I am not getting B's call to viewDidAppear. I am planning to do something when B's dismissed.

Upvotes: 4

Views: 5519

Answers (3)

nfarshchi
nfarshchi

Reputation: 1000

As I tested now viewDidAppear is calling when the view come to screen. even 1px. and even if you cover it by any other subView and again discover it this method will NOT call again.

It means it will call only after the subView appear for the first time. unless you remove it and add it again. in your question viewdidAppear of "C" is not calling again after you remove "D".

Upvotes: 2

Sanchit Paurush
Sanchit Paurush

Reputation: 6162

What I think, viewDidAppear is not called while adding or removing a subview. The reason behind this is, there are several objects which we add/remove to the view as subview. In this, viewDidAppear will be called again and again which is not a good mechanism. viewDidAppear is called when you load a class object on the current view and move the screen to another class's view and then return to the previous class. In short if you Push a navigationcontroller to a new view and then pop it to the older view then viewDidAppear is Called.

Upvotes: 2

mkral
mkral

Reputation: 4085

viewDidAppear will not be called when you dismiss a modal view. Think of a modal view as a view on top on the view.

Upvotes: 5

Related Questions