ios 无法实例化 UIMainStoryboardFile 'Main' 的默认视图控制器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24100210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to instantiate the default view controller for UIMainStoryboardFile 'Main'
提问by jaredsmith
I am trying to create a new Swift project and am having some issues. I tried to create a new single page application but when I build I get an error saying:
我正在尝试创建一个新的 Swift 项目,但遇到了一些问题。我试图创建一个新的单页应用程序,但是当我构建时,我收到一条错误消息:
2014-06-07 11:04:13.752 Matchismo (Swift)[2007:598021] Failed to instantiate
the default view controller for UIMainStoryboardFile 'Main' - perhaps the
designated entry point is not set?
But when I create the same single page application project with Objective-C as the language, it compiles and runs just fine. Is there some manual thing I must do in Swift to get a project up and running?
但是当我使用 Objective-C 作为语言创建相同的单页应用程序项目时,它编译并运行得很好。我必须在 Swift 中做一些手动操作才能启动并运行项目吗?
My understanding for this error is that I need the default view to be set, which is merely checking a box on your view controller's attributes (picture below). I tried the solution suggested in thisstackoverflow post but it didnt help and I can't find much more help on the subject with Swift being so new. Any suggestions are appreciated.
我对这个错误的理解是我需要设置默认视图,这只是选中视图控制器属性上的一个框(下图)。我尝试了这个stackoverflow 帖子中建议的解决方案,但它没有帮助,而且我无法在 Swift 如此新的主题上找到更多帮助。任何建议表示赞赏。
回答by user6919809
Select the ViewController Scene. Now, select the inspector panel from the sidebar options. Check the “Is Initial View Controller” attribute option, save the project and build the project again.
选择 ViewController 场景。现在,从侧边栏选项中选择检查器面板。选中“Is Initial View Controller”属性选项,保存项目并再次构建项目。
回答by Shane
Some times it doesn't take the initial view controller.Just create a new storyboard with anyname you want and set that name into the interface in your application setting.
有时它不需要初始视图控制器。只需使用您想要的任何名称创建一个新的故事板,并将该名称设置到您的应用程序设置的界面中。
Copy paste the code from previous storyboard and run the app. The application will run fine. Dont forget tocheck the initial scene in storyboard.
复制粘贴上一个故事板中的代码并运行应用程序。该应用程序将运行良好。不要忘记检查故事板中的初始场景。
回答by Deepak Singhvi
By following the below steps, it would work fine:
按照以下步骤,它会正常工作:
- Select the Scene which is the type of ViewController/UICollectionViewController in Main.storyboard.
- Select the Attribute Inspector in the right sidebar.
- Click/Check the “Is Initial View Controller” attribute.
- Re-Run of the project and this should solve the issue.
- 在 Main.storyboard 中选择 ViewController/UICollectionViewController 类型的场景。
- 在右侧边栏中选择属性检查器。
- 单击/检查“是初始视图控制器”属性。
- 重新运行项目,这应该可以解决问题。