To form a parent-child relationship:
- Send the
-addChildViewController:
message to the parent with the child as the parameter. This will send the-willMoveToParentViewController:
message to the child with the parent as the parameter. - Add the child view controller's
view
as a subview to the parent view controller'sview
. - Send the
-didMoveToParentViewController:
message to the child with the parent as the parameter.
For example,
[parent addChildViewController:child];