Why add subview again after adding a child view controller?

Since I have a parent view controller and a child,
the parent view controller is something like a container controller that apple doc said
then do

[parentVC addChildViewController:childVC]; childVC.view.frame = SOMEFRAME; 

but now childVC is not displayed on the screen; Should I add the code below?

 [parentVC.view addSubview:childVC.view];//is a must? any code can replace? 

- Page In my opinion, a container is a container, when I added childVC, it must add itself, or some method can do it.

UIWindow has the property "rootViewController", when you install it, a new view will be added automatically, I think this is what I want.

I need some advice. Thanks.

+4
source share
1 answer

This is a simple matter of control. Often you want to have a child view controller, but this view is subtype for one of your subzones, and not just for the presentation property of the top level view of the container controller.

Essentially, the framework decides what you decide, and does not ensure that the containing view controller's view is the first generation of its parent view controller. It is entirely up to you; for the hierarchy of ViewControllers and Views, there is no need for perfect generation parity.

+6
source

All Articles