Created
July 13, 2015 07:37
-
-
Save zh-se/13b436235d4ad7b3bd46 to your computer and use it in GitHub Desktop.
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
// 1. A property has the same name as a segue identifier in XIB | |
@property (nonatomic) ChildViewController1 *childController1; | |
@property (nonatomic) ChildViewController2 *childController2; | |
// #pragma mark - UIViewController | |
- (void)prepareForSegue:(UIStoryboardSegue *)segue | |
sender:(id)sender | |
{ | |
[super prepareForSegue:segue sender:sender]; | |
// 2. All known destination controllers assigned to properties | |
if ([self respondsToSelector:NSSelectorFromString(segue.identifier)]) { | |
[self setValue:segue.destinationViewController forKey:segue.identifier]; | |
} | |
} | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// 3. Controllers already available bc viewDidLoad is called after prepareForSegue | |
self.childController1.view.backgroundColor = [UIColor redColor]; | |
self.childController2.view.backgroundColor = [UIColor blueColor]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment