Addingremoving a child view controller
suggest changeTo add a child view controller:
- (void)displayContentController:(UIViewController *)vc {
[self addChildViewController:vc];
vc.view.frame = self.view.frame;
[self.view addSubview:vc.view];
[vc didMoveToParentViewController:self];
}
To remove a child view controller:
- (void)hideContentController:(UIViewController *)vc {
[vc willMoveToParentViewController:nil];
[vc.view removeFromSuperview];
[vc removeFromParentViewController];
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents