解决Failed to instantiate the default view controller for UIMainStoryboardFile 'Main'

来源:互联网 发布:最早的陶器知乎 编辑:程序博客网 时间:2024/05/22 12:05

Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?

这个问题困扰了好长时间,网上好多人给的方案是需勾选,实际上,创建工程时,自动声称的main。storyboard中,这个选项默认就是勾选的,但是还是报同样的错误。

解决方案如下:

1、在工程文件中新建一个storyboard,自定义名称(my.storyboard)

2、点击自动声称的main.storyboard中的空白处,(红色区域),敲击command+A选中storyboard中的所有内容,command+C复制

3、点击自己创建的my.storyboard,command+V粘贴,这时,原storyboard中的内容已全部复制到新创建的storyboard中

4、确认勾选Is initial View Controller

5、点击Run,这时可能会报错:loaded the “view” nib but the view outlet was not set,这是因为这里没有做与ViewController的关联

6、

,点击红色区域,拖拽至View Controller,松开鼠标,发现原来置灰的view已变成viewController

7、点击菜单栏Product下的clean,然后点击Run重新运行,正常通过


0 0