Skip to content

Instantly share code, notes, and snippets.

@b9AobJ
Forked from tomohisa/gist:2897676
Created August 17, 2016 06:30
Show Gist options
  • Save b9AobJ/21f78566b50d5516a7c0a3e5b9b77e3a to your computer and use it in GitHub Desktop.
Save b9AobJ/21f78566b50d5516a7c0a3e5b9b77e3a to your computer and use it in GitHub Desktop.
Add and Remove ChildViewController
// add child view
UIViewController* controller = [self.storyboard instantiateViewControllerWithIdentifier:@"test"];
[self addChildViewController:controller];
controller.view.frame = CGRectMake(0, 44, 320, 320);
[self.view addSubview:controller.view];
[controller didMoveToParentViewController:self];
// remove child view
UIViewController *vc = [self.childViewControllers lastObject];
[vc.view removeFromSuperview];
[vc removeFromParentViewController];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment