Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get StoryBoard instance of View Controller

Example without storyboard:

AppDelegate.h

@property (retain, nonatomic) UIViewController *leftController;

AppDelegate.m

self.leftController = [[LeftViewController alloc] initWithNibName:@"LeftViewController" bundle:nil];

OtherViewController:

//This is what I want do to in storyboards
self.viewDeckController.leftController = (AppDelegate*)[[UIApplication sharedApplication] delegate].leftController;

How can I get that instance of leftController when using storyboards?

like image 844
1337code Avatar asked Dec 06 '12 15:12

1337code


1 Answers

You can give the view controller an identifier in interface builder, then simply use:

UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"myStoryBoardName" bundle:nil];
self.leftController = [mystoryboard instantiateViewControllerWithIdentifier:@"idyouassigned"];
like image 129
Mick MacCallum Avatar answered Nov 11 '22 17:11

Mick MacCallum