查看文件所有者无法使用的插座 [英] View outlet not available to File's Owner

查看:143
本文介绍了查看文件所有者无法使用的插座的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建新的视图控制器时收到以下消息。一切都在Xcode编译没有错误,但应用程序立即退出从一个RootViewController加载新的视图。

 由于未捕获异常NSInternalInconsistencyException而终止应用程序,原因:' -  [UIViewController _loadViewFromNibNamed:bundle:]加载了HomeViewnib但是未设置视图出口'

为了解决这个问题,我尝试将文件的所有者连接到视图,但文件所有者甚至不能使用视图出口。

解决方案

根据@Tim Post的建议从问题部分移出。



发现



我终于意识到当我添加这个View XIB时,文件的Owner已经设置为NSObject而不是HomeViewController处理视图控制器)。一旦我在indentity检查器中设置类标识,视图出口就准备连接到视图。



现在加载应用程序,新视图完美加载。



结束语:

创建一个新的View XIB,确保在indentity检查器(Cmd + 4)中将类标识设置为所需的视图控制器。默认情况下可以设置为NSObject。



视图出口应该可用。


I was getting the following message upon creating a new view controller. Everything was compiling a-okay in Xcode without errors, but the app was immediately quitting upon loading the new view from a RootViewController.

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

To resolve this, I tried connecting the File's Owner to the view, but the view outlet wasn't even available to the File's owner.

解决方案

Moved from question section, per @Tim Post's suggestion.

Discovery:

I finally realized that when I added this View XIB, the File's Owner had been set to NSObject instead of HomeViewController (my newly-created view controller). Once I set the class identity in the indentity inspector, the view outlet was then ready to be connected to the view.

The app now loads and the new view loads perfectly. Just sharing for the benefit of the SO community.

Conclusion:

When creating a new View XIB, make sure to set the class identity to the desired view controller in the indentity inspector (Cmd+4). It may be set to NSObject by default.

The view outlet should then be available.

这篇关于查看文件所有者无法使用的插座的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆