Episode #58

Container View Controllers

15 minutes
Published on March 21, 2013

This video is only available to subscribers. Get access to this video and 573 others.

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