Last active
May 15, 2016 11:55
-
-
Save onmyway133/9978108 to your computer and use it in GitHub Desktop.
View Controller Containment
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
// Adding A Child View Controller | |
[self addChildViewController:viewController]; | |
viewController.view.frame = self.view.bounds; | |
[self.view addSubview:viewController.view]; | |
[viewController didMoveToParentViewController:self]; | |
// Removing A Child From A Parent | |
[viewController willMoveToParentViewController:nil]; | |
[viewController.view removeFromSuperview]; | |
[viewController removeFromParentViewController]; | |
// Replace | |
// Containment | |
[self addChildViewController:vc]; | |
[self.currentVC willMoveToParentViewController:nil]; | |
[self transitionFromViewController:self.currentVC | |
toViewController:vc | |
duration:0.25 | |
options:0 | |
animations:^ | |
{ | |
// Do any fancy animation you like | |
} completion:^(BOOL finished) { | |
[vc didMoveToParentViewController:self]; | |
[self.currentVC removeFromParentViewController]; | |
self.currentVC = vc; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment