Created
September 8, 2014 12:22
-
-
Save fjolnir/2ccd1e114355bfb89cc4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#import "CYContainerViewController.h" | |
@implementation CYContainerViewController | |
- (void)setContainedViewController:(UIViewController * const)aController | |
{ | |
[self willChangeValueForKey:@"containedViewController"]; | |
[self.containedViewController willMoveToParentViewController:nil]; | |
[self.containedViewController removeFromParentViewController]; | |
[self.containedViewController.view removeFromSuperview]; | |
[self.containedViewController didMoveToParentViewController:nil]; | |
aController.view.frame = self.view.bounds; | |
aController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | |
[aController willMoveToParentViewController:self]; | |
[self addChildViewController:aController]; | |
[self.view addSubview:aController.view]; | |
[aController didMoveToParentViewController:self]; | |
_containedViewController = aController; | |
[self didChangeValueForKey:@"containedViewController"]; | |
} | |
@end | |
@implementation CYContainmentSegue | |
- (void)perform | |
{ | |
NSAssert([self.sourceViewController isKindOfClass:[CYContainerViewController class]], | |
@"CYContainmentSegue must be used with a CYContainerViewController."); | |
CYContainerViewController * const container = self.sourceViewController; | |
container.containedViewController = self.destinationViewController; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment