Container View Controllers

Episode #58 | 15 minutes | published on March 21, 2013
Subscribers Only
In this episode I create a container view controller using the UIViewController containment APIs. The container view controller mimicks a style where the starting view controller fades into the background instead of sliding to the left.

Episode Links

Adding a child view controller

A few things need to happen, in order, when adding a child view controller:

  1. send willMoveToParentViewController: to the child view controller being added
  2. Call addChildViewController: to add it to the childViewControllers collection
  3. Add the child view into the view hierarchy
  4. Call didMoveToParentViewController:

Removing a child view controller

Similar to above, to remove a view controller, the following must be done (in order):

  1. Call willMoveToParentViewController: passing in nil as the argument
  2. Remove the view from the hierarchy
  3. Call removeFromParentViewController on the child view controller
blog comments powered by Disqus