Last active
August 29, 2015 13:57
-
-
Save izackp/9413365 to your computer and use it in GitHub Desktop.
A quick implementation of adding a child view controller to another view controller and specifies which view to add it to.
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
@interface UIViewController (AddChild) | |
- (void)addChildController:(UIViewController*)childController toView:(UIView*)view; | |
@end | |
@implementation UIViewController (AddChild) | |
- (void)addChildController:(UIViewController*)childController toView:(UIView*)view { | |
[childController willMoveToParentViewController:self]; | |
childController.view.frame = view.bounds; | |
[view addSubview:childController.view]; | |
[self addChildViewController:childController]; | |
[childController didMoveToParentViewController:self]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment