Pushing a view controller (VC) onto the navigation controller stack makes VC the child view controller of the navigation controller (which is the container controller). Creating such a parent-child relationship is a separate step that does not immediately load the child VC view. Rather, the VC container loads the view later. I believe that there is no explicit specification of what βlaterβ means - it will usually be when the VC container has decided that it is time to integrate the child VC view into the hierarchy of viewing the VC container. But basically it just happens at the discretion of the VC container implementation.
At the same time, anyone can make VC view load with simple access to the VC view property. For example, in your code you can add this line
myVC.view;
which launches loadView and then viewDidLoad in MyViewController .
However, in your case, if MyViewController should respond to an event associated with the VC container, then it would be better to override one (or both?) MyViewController following methods in MyViewController :
- (void) willMoveToParentViewController:(UIViewController*)parent {
However, you need to know that willMoveToParentViewController and didMoveToParentViewController also called when MyViewController unloaded from its parent navigation controller stack. You may find this to be true by checking the parent argument for nil .
source share