Reputation: 762
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
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