简体   繁体   English

无法实例化UIMainStoryboardFile'Main'的默认视图控制器

[英]Failed to instantiate the default view controller for UIMainStoryboardFile 'Main'

I am trying to create a new Swift project and am having some issues. 我正在尝试创建一个新的Swift项目,并且遇到了一些问题。 I tried to create a new single page application but when I build I get an error saying: 我试图创建一个新的单页应用程序,但是在构建时出现错误消息:

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. 但是,当我使用Objective-C作为语言创建相同的单页应用程序项目时,它可以编译并运行良好。 Is there some manual thing I must do in Swift to get a project up and running? 我必须在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 this stackoverflow post but it didnt help and I can't find much more help on the subject with Swift being so new. 我尝试了这个 stackoverflow帖子中建议的解决方案,但它没有帮助,而且Swift这么新,我在该主题上找不到更多帮助。 Any suggestions are appreciated. 任何建议表示赞赏。

我的主视图控制器

屏幕截图错误

Select the ViewController Scene. 选择ViewController场景。 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. 选中“是初始视图控制器”属性选项,保存项目并再次构建项目。

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 following the below steps, it would work fine: 通过执行以下步骤,可以正常工作:

  1. Select the Scene which is the type of ViewController/UICollectionViewController in Main.storyboard. 在Main.storyboard中选择场景,该场景是ViewController / UICollectionViewController的类型。
  2. Select the Attribute Inspector in the right sidebar. 在右侧栏中选择属性检查器。
  3. Click/Check the “Is Initial View Controller” attribute. 单击/选中“是初始视图控制器”属性。
  4. Re-Run of the project and this should solve the issue. 重新运行该项目,这应该可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法为 UIMainStoryboardFile 'Main' 实例化默认视图 controller - 也许未设置指定的入口点? - Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set? 未能为 UIMainStoryboardFile 'Main' 实例化默认视图 controller - 也许未设置指定的入口点? - Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set? 如何清除“无​​法实例化默认视图控制器”警告? - How to remove “Failed to instantiate the default view controller” warning? 从 .xcodeproj 切换到 .xcworkspace 后无法实例化默认视图控制器 - Failed to instantiate the default view controller after switching from .xcodeproj to .xcworkspace 无法实例化默认视图控制器? - cannot instantiate default view controller? 无法实例化视图控制器。 - 斯威夫特 - Failed to instantiate view controller. - Swift 无法实例化View Controller - Unable to Instantiate View Controller 在视图 controller 中实例化视图 controller 是否可能/智能? - Is it possible / smart to instantiate a view controller in a view controller? 在AppDelegate上实例化视图控制器,了解 - Instantiate a view controller on AppDelegate, understanding Swift-在AppDelegate中实例化视图控制器 - Swift - Instantiate View Controller in AppDelegate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM