0
votes

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.

2
Probably, you have added Space as prefix or as prefix of storyboard ID in storyboard or in code.. So, please check for spaces if by mistake added - Mehul Thakkar
Please mark my answer as correct if my answer solves your error :) Cheers - user5890979

2 Answers

1
votes

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.

1
votes

Please make sure you have set Storyboard ID in storyboard

enter image description here