xcode UIViewController _loadViewFromNibNamed:bundle 加载了“XXXViewController”笔尖,但未设置视图插座。-*使用故事板*

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13394099/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:06:15  来源:igfitidea点击:

UIViewController _loadViewFromNibNamed:bundle loaded the "XXXViewController" nib but the view outlet was not set.' -*Using Storyboard*

xcodeuinavigationcontrollerstoryboardnib

提问by Vince613

I am using Storyboard to navigate through my View Controllers. I have my Root View Controller called (RootVC) which I've hooked up to the next view controller (called SecondVC) with a 'push' segue. I have a button in RootVC that when pressed calls pushViewController. When I run this, I end up seeing the following error:

我正在使用 Storyboard 浏览我的视图控制器。我有一个名为 (RootVC) 的根视图控制器,我通过“推”segue 将它连接到下一个视图控制器(称为 SecondVC)。我在 RootVC 中有一个按钮,按下时会调用pushViewController. 当我运行它时,我最终看到以下错误:

*Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "SecondVC" nib but the view outlet was not set.'

*由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“-[UIViewController _loadViewFromNibNamed:bundle:] 加载了“SecondVC”笔尖但未设置视图出口。

I've looked around and seen a lot of people suggesting that the UIView is not properly hooked up in the xib. I'm using Storyboard so it's a little different, but I can still see that my SecondVC's view outlet is connected to the UIView that belongs to it. By the looks of it, Storyboard makes this association by default.

我环顾四周,看到很多人表示 UIView 没有正确连接到 xib 中。我正在使用 Storyboard,所以它有点不同,但我仍然可以看到我的 SecondVC 的视图插座连接到属于它的 UIView。从外观上看,Storyboard 默认情况下会进行此关联。

Anyone have any ideas of what could be going wrong? If a screenshot of my Storyboard is needed I can provide that.

任何人都知道可能会出什么问题?如果需要我的故事板的屏幕截图,我可以提供。

Thanks in advance.

提前致谢。

回答by hook38

I had the same issue, make sure you do not have

我有同样的问题,确保你没有

@synthesize view; 

in you viewcontroller .m file.

在您的 viewcontroller .m 文件中。

回答by JohnVanDijk

In your storyboard, right click on the File's owner and select your view as it's view outlet.

在您的故事板中,右键单击文件的所有者并选择您的视图作为视图出口。

回答by Vincent

The name 'View' for the view is a reserved name. When you want to synthesize a view named 'View' this error will occur.

视图的名称“View”是保留名称。当您要合成名为“View”的视图时,会发生此错误。

Solution is to rename the view to your own name.

解决方案是将视图重命名为您自己的名称。

回答by over_optimistic

I don't know just giving ideas

我不知道只是提供想法

You probably already seen this 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the GameView nib but the view outlet was not set

您可能已经看到了这个 “NSInternalInconsistencyException”,原因:“-[UIViewController _loadViewFromNibNamed:bundle:] 加载了 GameView nib 但未设置视图插座

It has to do with a connection. The class name of the View controller element in interface builder should match up with the class name (case sensitive) with the appropriate class that derives from UIViewController. You should not need to create an IBOutlet of named view. Doing a clean might help. It could be a typo in your code too.

它与连接有关。界面构建器中视图控制器元素的类名应该与类名(区分大小写)与派生自 UIViewController 的适当类相匹配。您不需要创建命名视图的 IBOutlet。做一次清洁可能会有所帮助。它也可能是您代码中的错字。