Created
June 14, 2013 01:35
-
-
Save stephsharp/5778803 to your computer and use it in GitHub Desktop.
Embed Segue for iOS5
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
// | |
// iOS5EmbedSegue.h | |
// Created by Stephanie Sharp on 2/05/13. | |
// | |
#import <UIKit/UIKit.h> | |
@interface iOS5EmbedSegue : UIStoryboardSegue | |
@property (nonatomic, strong) UIView * containerView; | |
@end |
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
// | |
// iOS5EmbedSegue.m | |
// Created by Stephanie Sharp on 2/05/13. | |
// | |
// Helpful links: | |
// http://stackoverflow.com/questions/14432310/embed-segue-ios-5 | |
// http://www.quentamia.com/blog/embed-segue-in-ios-5/ | |
#import "iOS5EmbedSegue.h" | |
@implementation iOS5EmbedSegue | |
@synthesize containerView; | |
- (void)perform | |
{ | |
if (!self.containerView) | |
self.containerView = [self.sourceViewController view]; | |
[self.sourceViewController addChildViewController:self.destinationViewController]; | |
[self.containerView addSubview:[self.destinationViewController view]]; | |
[self.destinationViewController didMoveToParentViewController:self.sourceViewController]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
containerView
property, it will default to thesourceViewController
'sview
. Otherwise, the segue will embed thedestinationViewController
in thecontainerView
.containerView
in the storyboard.I set the
containerView
in theprepareForSegue:sender:
method. For example: