UIStoryboard Could not find view controller with id

I have an ios application using storyboards with a bunch of view controllers.

After adding a new ViewController and setting the identifier (storyboard identifier) enter image description here

I am trying to instantiate a new ViewController with the following code:

SurveyNewViewController *newSurvey = [[self storyboard] instantiateViewControllerWithIdentifier:@"newSurveyView"]; [self presentViewController:newSurvey animated:YES completion:nil]; 

Everything seems to be correct, but when the application starts on the simulator, it crashes:

 ** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0xa340fa0>) doesn't contain a view controller with identifier 'newSurveyView'' 

Are there any possible explanations? I used the same approach in different places of the system and it works well.

+7
ios uistoryboard xcode-storyboard
source share
3 answers

Try to remove the application from iPhone Simulator, clean the project and create it after the project starts.

+37
source share

Try with this:

 [[UIStoryboard storyboardWithName:@"StoryboardNameOfnewSurveyView" bundle:nil] instantiateViewControllerWithIdentifier:@"newSurveyView"]; 

If this works, I think [self storyboard] is not giving you the right object;).

+4
source share

Set the Storyboard ID as it is used in Xcode 8.0 and check the Use Storyboard ID parameter. Also check that the Class field is set in the Storyboard on the ViewController .

Dialog screenshot

0
source share

All Articles