When is viewDidAppear called?

If I have a UIViewController called B. If I add UIViewController C as the subview / child view controller from B. Then I will add D as the child view controller B, too. Then I remove D from B. In this case, should I call C viewDidAppear?

I ask because I do not receive a B call to viewDidAppear. I plan to do something when B is fired.

+3
source share
3 answers

viewDidAppear will not be called when the modal view is disabled. Think of a modal view as a top view of a view.

+5
source

What I think, viewDidAppear is not called when adding or removing views. The reason for this is that there are several objects that we add / remove to the view as a subview. In this case, viewDidAppear will be called again and again, which is not a good mechanism. viewDidAppear is called when you load a class object into the current view and move the screen to another view of the class, and then return to the previous class. In short, if you click on the navigation controller on a new view, and then place it in an older view, then viewDidAppear is called.

+2
source

As I tested now, viewDidAppear calls when the view appears on the screen. even 1px. and even if you cover it with any other subView and again find that this method will NOT call again.

This means that it will be called only after the appearance of subView for the first time. unless you delete it and add it again. in your question viewDidAppear in "C" is not called again after deleting "D".

+2
source

All Articles