未使用 UINavigationController 设置视图出口
我有一个包含 UINavigationController
的 NIB,其中包含 UIViewController
。 UIViewController
正在从另一个笔尖外部加载。我无法设置视图属性,因此出现错误:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "LBRootViewController" nib but the view outlet was not set.'
如何正确设置视图属性?
I have a NIB that contains a UINavigationController
which has a UIViewController
. The UIViewController
is being loaded externally from another nib. I am unable to set the view property thus I get the error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "LBRootViewController" nib but the view outlet was not set.'
How can I set my view property correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有一个
LBRootViewController.xib
的 nib 文件。该笔尖内部是一个视图控制器子类,它有一个名为view
的插座。该插座未设置。当您的(默认名称)
MainWindow.xib
加载时,它会实例化LBRootViewController
的实例,但随后发现控制器没有视图出口,这意味着它无法显示任何内容。您需要检查的笔尖是
LBRootViewController.xib
,而不是MainWindow.xib
。如果由于某种原因,
LBRootViewController.xib
中的LBRootViewController
对象没有 view 属性,那么您将该对象设置为错误的类,即 UIViewController 子类以外的类。You have a nib file of
LBRootViewController.xib
. Inside that nib is a view controller subclass that has an outlet namedview
. That outlet is not set.When your (default name)
MainWindow.xib
loads, it instantiates an instance ofLBRootViewController
but then finds that the controller has no view outlet meaning it cannot display anything.The nib you need to examine is
LBRootViewController.xib
and notMainWindow.xib
.If for some reason the
LBRootViewController
object inLBRootViewController.xib
doesn't have a view property, then you have set the object to the wrong class i.e. something other than a UIViewController subclass.我认为您没有在界面生成器中为“文件所有者”分配“视图”属性。 (如果文件的所有者是 UIViewController)
I think you did not assign a 'view' property for the 'File's Owner' at the Interface Builder. (if file's owner is UIViewController)