Created
July 25, 2012 01:09
-
-
Save tomohisa/3173776 to your computer and use it in GitHub Desktop.
Add ChildViewController Help Method.
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
#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