Forte Zhu
Forte Zhu

Reputation: 762

Error:Storyboard doesn't contain a view controller with identifier 'jailBrokenViewController''

I am working on an app. I try using Storyboard ID, to move from one ViewController to other ViewController. I used following code, after setting storyboard ID (Screenshot attached),

jailBrokenViewController *jailBrokenViewController=[self.storyboard instantiateViewControllerWithIdentifier:@"jailBrokenViewController"];
[self presentViewController:jailBrokenViewController animated:YES completion:nil];

Screenshot of storyboard:StoryBoard ID Clarification

I am getting error:

2017-01-24 15:02:07.639 demoObjC[1109:300901] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard () doesn't contain a view controller with identifier 'jailBrokenViewController''

XCode Version I am using is 8.2.1.

Upvotes: 0

Views: 1567

Answers (2)

Hardik Gondaliya
Hardik Gondaliya

Reputation: 135

Please make sure you have set Storyboard ID in storyboard

enter image description here

Upvotes: 2

user5890979
user5890979

Reputation:

Initializing like this to avoid errors:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

jailBrokenViewController *jailBrokenViewController=[sb instantiateViewControllerWithIdentifier:@"jailBrokenViewController"];
[self presentViewController:jailBrokenViewController animated:YES completion:nil];

Note: You change the "Main" to your correct storyboard name.

Upvotes: 1

Related Questions