1337code
1337code

Reputation: 169

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?

Upvotes: 9

Views: 20341

Answers (2)

Amitg2k12
Amitg2k12

Reputation: 3805

I am not sure whether you able to get solutions of this problem or not, but you can also refer the answer of this question :

Accessing view controller form a storyboard

Upvotes: 0

Mick MacCallum
Mick MacCallum

Reputation: 130183

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"];

Upvotes: 28

Related Questions