Xcode“-[UIViewController _loadViewFromNibNamed:bundle:] 加载了笔尖但未设置视图插座。” 错误

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

Xcode "-[UIViewController _loadViewFromNibNamed:bundle:] loaded the nib but the view outlet was not set." error

iphonexcodexcode4xibnib

提问by austin

I'm using Xcode 4 and when I run my app, the first screen doesn't load. It fails in the simulators and on a device. I've searched for answers and they all say to make sure I've dragged the circles in Files Owner to the correct views. Sorry I don't remember the names of the things, I'm new to Xcode. I've dragged the circles to the correct view and tried many things but none of them worked. What could I be doing wrong?

我使用的是 Xcode 4,当我运行我的应用程序时,第一个屏幕没有加载。它在模拟器和设备上失败。我已经搜索了答案,他们都说要确保我已将 Files Owner 中的圆圈拖到正确的视图中。抱歉,我不记得这些东西的名字了,我是 Xcode 的新手。我已经将圆圈拖到正确的视图并尝试了很多东西,但没有一个起作用。我可能做错了什么?

Here is the full error:

这是完整的错误:

2012-02-19 12:59:54.655 Ponyboard[271:207]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "PonyboardViewController" nib but the view outlet was not set.' 

*** Call stack at first throw:  
(  
    0   CoreFoundation                      0x00f095a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x0105d313 objc_exception_throw + 44
    2   CoreFoundation                      0x00ec1ef8 +[NSException raise:format:arguments:] + 136
    3   CoreFoundation                      0x00ec1e6a +[NSException raise:format:] + 58
    4   UIKit                               0x0020d709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
    5   UIKit                               0x0020b134 -[UIViewController loadView] + 120
    6   UIKit                               0x0020b00e -[UIViewController view] + 56
    7   UIKit                               0x0017ed42 -[UIWindow addRootViewControllerViewIfPossible] + 51
    8   Ponyboard                           0x00002a87 -[PonyboardAppDelegate application:didFinishLaunchingWithOptions:] + 135
    9   UIKit                               0x0015bc89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
    10  UIKit                               0x0015dd88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
    11  UIKit                               0x00168617 -[UIApplication handleEvent:withNewEvent:] + 1533
    12  UIKit                               0x00160abf -[UIApplication sendEvent:] + 71
    13  UIKit                               0x00165f2e _UIApplicationHandleEvent + 7576
    14  GraphicsServices                    0x031fd992 PurpleEventCallback + 1550
    15  CoreFoundation                      0x00eea944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    16  CoreFoundation                      0x00e4acf7 __CFRunLoopDoSource1 + 215
    17  CoreFoundation                      0x00e47f83 __CFRunLoopRun + 979
    18  CoreFoundation                      0x00e47840 CFRunLoopRunSpecific + 208
    19  CoreFoundation                      0x00e47761 CFRunLoopRunInMode + 97
    20  UIKit                               0x0015d7d2 -[UIApplication _run] + 623
    21  UIKit                               0x00169c93 UIApplicationMain + 1160
    22  Ponyboard                           0x000029c9 main + 121
    23  Ponyboard                           0x00002945 start + 53
)
terminate called after throwing an instance of 'NSException'

回答by Nick

Are you sure you have a UIView (or subclass) assigned to the "view" property of PonyboardViewController? Right click on "File Owner" in the left pane of the xib for PonyboardViewController and verify that the "view" outlet is set.

你确定你有一个 UIView(或子类)分配给 PonyboardViewController 的“view”属性吗?在 PonyboardViewController 的 xib 的左窗格中右键单击“文件所有者”,并验证“视图”插座已设置。

If not, set it to a view!

如果没有,请将其设置为视图!

回答by Levine Veblen

I just have the same problem as you, so I fixed it like that: this is my code block:

我和你有同样的问题,所以我是这样解决的:这是我的代码块:

self.chatsView = [[ChatsView alloc] initWithNibName:@"ChatsView" bundle:nil];

I click ChatsView.xibto find the "File's owner", then hover my mouse over the "File's owner", and right click, that will prompt something like this:

我单击ChatsView.xib找到“文件的所有者”,然后将鼠标悬停在“文件的所有者”上,然后右键单击,将提示如下内容:

The unconnected 'view' outlet

未连接的“视图”插座

you must drag the "view" Outlet to connect to the Viewwhich have two subViews: Search Bar&Table View in my xib file.

你必须拖动“视图”插座连接到视图具有两个子视图:搜索栏和表视图在我的厦门国际银行文件。

The connected 'view' outlet

连接的“视图”插座

回答by A.G

Your problem probably lies with the XIB or Stroyborad scene. Check whether the View is connected properly to the class.

您的问题可能出在 XIB 或 Stroyborad 场景中。检查 View 是否正确连接到类。

I've tried, and it works fine for me after doing it.

我试过了,做完之后对我来说效果很好。