I’m trying to create a container view controller using iOS5 and new methods like addChildViewController.
Do I have to call addSubview after calling addChildViewController?
Do I have to call removeFromSuperview before calling removeChildViewController?
I don’t see anything about this in Apple docs.
What do you think?
Short answer: “Yes, and yes.” The view hierarchy and the view controller hierarchy are still independent. The containment API simply allows views from other controllers to present themselves within a parent controller’s view in a clean and consistent way.
You can find a bit in Apple’s docs here… this is a relevant passage from the “Container View Controllers Arrange Content of Other View Controllers” section:
If you have access, I would highly recommend checking out the WWDC 2011 video entitled “Implementing UIViewController Containment” (download it from Apple Developer Video Archive).