Skip to content

Instantly share code, notes, and snippets.

@tomohisa
Created July 25, 2012 01:09
Show Gist options
  • Save tomohisa/3173776 to your computer and use it in GitHub Desktop.
Save tomohisa/3173776 to your computer and use it in GitHub Desktop.
Add ChildViewController Help Method.
#pragma mark - help functions
-(void) addChildViewControllerWithIdentifier:(NSString*)identifier inArea:(CGRect)rect closeOtherChildView:(BOOL)isClose toView:(UIView*) toView{
if (isClose) {
for (UIViewController* vc in self.childViewControllers) {
[vc.view removeFromSuperview];
[vc removeFromParentViewController];
}
}
UIViewController* controller;
controller = [self.storyboard instantiateViewControllerWithIdentifier:identifier];
[self addChildViewController:controller];
controller.view.frame = rect;
[toView addSubview:controller.view];
[controller didMoveToParentViewController:self];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment