Skip to content

Instantly share code, notes, and snippets.

@sebk
Last active January 4, 2016 03:28
Show Gist options
  • Save sebk/8561636 to your computer and use it in GitHub Desktop.
Save sebk/8561636 to your computer and use it in GitHub Desktop.
Add/Remove ChildViewController
//add:
UIViewController *childVC = ...;
[childVC willMoveToParentViewController:self];
[self addChildViewController:childVC];
[self.view addSubview:childVC.view];
//set frame or constraints of childVC.view
[childVC didMoveToParentViewController:self];
//remove:
[childVC willMoveToParentViewController:nil];
[childVC.view removeFromSuperview];
[childVC removeFromParentViewController];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment