Created
January 14, 2015 16:56
-
-
Save ijoshsmith/ea613776411746a8c2d3 to your computer and use it in GitHub Desktop.
Adding and removing child view controllers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// These methods assume that `self` references a UIViewController instance. | |
- (void)loadChildViewController:(UIViewController *)viewController | |
{ | |
[self addChildViewController:viewController]; | |
[self.view addSubview:viewController.view]; | |
[viewController didMoveToParentViewController:self]; | |
} | |
- (void)unloadChildViewController:(UIViewController *)viewController | |
{ | |
[viewController willMoveToParentViewController:nil]; | |
[viewController.view removeFromSuperview]; | |
[viewController removeFromParentViewController]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment