Created
October 12, 2014 23:25
-
-
Save anthonycastelli/7e8a8cdf7ac3a21e86a6 to your computer and use it in GitHub Desktop.
Child View Controllers
This file contains 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
- (void)replaceViewController:(UIViewController *)replacementViewController { | |
// Load the new view controller | |
[self addChildViewController:replacementViewController]; | |
[replacementViewController.view setFrame:self.view.bounds]; | |
[self.view addSubview:replacementViewController.view]; | |
[replacementViewController didMoveToParentViewController:self]; | |
// Get rid of the old one | |
[self.selectedViewController willMoveToParentViewController:nil]; | |
[self.selectedViewController.view removeFromSuperview]; | |
[self.selectedViewController removeFromParentViewController]; | |
self.selectedViewController = replacementViewController; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment