Sean Cleveland
Sean Cleveland

Reputation: 143

setViewController with Storyboard

I am trying go from one view controller to another using a navigation menu. My problem is it will access the code from AddNewHomeTableViewController, but will not access my view controller from the storyboard. Below is how I access the code:

AddNewHomeTableViewController *controller = [[AddNewHomeTableViewController alloc] init];
[weakSelf setViewControllers:@[controller] animated:YES];

Please and thank you!

Upvotes: 0

Views: 240

Answers (1)

rdelmar
rdelmar

Reputation: 104092

You don't access (or create as you do in your code) a view controller in a storyboard with alloc init. You use instantiateViewControllerWithIdentifier:.

AddNewHomeTableViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"AddHome"]; //be sure the identifier you use here is the same one you define in the storyboard

Upvotes: 1

Related Questions