我有一个ios应用程序使用故事板和一堆视图控制器.
添加新的ViewController后,配置了标识(Storyboard ID)
我尝试使用以下代码实例化新的ViewController:
SurveyNewViewController *newSurvey = [[self storyboard] instantiateViewControllerWithIdentifier:@"newSurveyView"]; [self presentViewController:newSurvey animated:YES completion:nil];
一切似乎都是正确的,但在模拟器上运行应用程序时崩溃:
** Terminating app due to uncaught exception 'NSInvalidArgumentException',reason: 'Storyboard (<UIStoryboard: 0xa340fa0>) doesn't contain a view controller with identifier 'newSurveyView''
解决方法
在运行项目后,尝试从iPhone模拟器中删除您的应用程序,清理项目并构建.