loaded some nib but the view outlet was not set(转载)

当使用 initWithNibName 函数, 并使用 由nib文件生成的ViewController 的view属性时候,遇到这个问题。

//load loc.xib

UIViewController * UIVC = [[UIViewController alloc] initWithNibName:@"loc" bundle:nil];

[self.view addSubview:UIVC.view];

[UIVC release];

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

表面意思是指 我们加载的nib文件,"view" 属性值没有进行设置.

这里的实际情况: 不是所生成的 VC 的view属性值为 nil,  而是所生成的 VC 没有 view 这个属性。 我们使用的是UIViewController 定义的VC, 为什么 VC (View Controller) 会没有 view 属性呢?

(多么具有逻辑性的表述都不如一次成功的完整操作,begin :)

解决方案:

1. 点击我们要加载的 xib 文件

2. 在右边选中 File‘s Owner

3. 在 File‘s Owner 的  选项卡的“Custom Class” 属性设置中,将 Class 的值改成对应的 VC, 这里改成 UIViewController,

4. 这时候,在File‘s Owner 的  选项卡中, 就 会出现“待连接设置” 的 view 属性, 也即我们的编译器 告诉我们的 the view outlet was not set  中的 view。当 File‘s Owner 的 class 为 NSObject 时候,是没有 view 属性的。

连接 view 属性,

5. win+r, OK.

http://www.cnblogs.com/TivonStone/archive/2012/04/20/2460116.html

时间: 2024-10-01 11:38:43

loaded some nib but the view outlet was not set(转载)的相关文章

loaded some nib but the view outlet was not set

当使用 initWithNibName 函数, 并使用 由nib文件生成的ViewController 的view属性时候,遇到这个问题. //load loc.xib UIViewController * UIVC = [[UIViewController alloc] initWithNibName:@"loc" bundle:nil]; [self.view addSubview:UIVC.view]; [UIVC release]; NibName[2203:207] ***

Bug:(使用xib加载控制器view时遇到的bug) loaded some nib but the view outlet was not set

当使用 initWithNibName 函数, 并使用 由nib文件生成的ViewController 的view属性时候,遇到这个问题. UIViewController * UIVC = [[UIViewController alloc] initWithNibName:@"loc" bundle:nil]; [self.view addSubview:UIVC.view]; NibName[2203:207] *** Terminating app due to uncaught

关于'-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "XXXView" nib but the view outlet was not set.'这个bug的原因

此种bug分为两种情况: 一:当你这个控制器的view是通过xib加载的,但是在xib里面并没有绑定file's Owner,或者绑定了file's Owner,但是没用对file's Owner里面的view属性进行连线 解决情况:第一步: : 第二步: 二:第二种出bug的原因可能很多人都会忽略,当你的控制器的文件名称跟你用xib描述的一个view的名称很像,就是少了一个controller,此时也会在运行的时候崩掉 例如 : 首先来分析:PPVideoViewController并没用用x

问题:-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "BlueView" nib but the view outlet was not set.

问题:‘-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "One" nib but the view outlet was not set.‘ 原因:没有做xib文件到HLOneViewControler程序的关联 解决步骤: 1, 打开xib文件 2, 点击"File‘s Owner",设置Class为xxxViewControler 3, 右键"Files‘s Owner&quo

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

当使用xib加载控制器的时候,报如下错误: -[UIViewController _loadViewFromNibNamed:bundle:] loaded the "RootViewController" nib but the view outlet was not set 原因: 控制器与xib没有关联 解决办法: 1.选择xib文件 2.控制器类关联 3.视图关联(拖线)

XIB加载 ---- [UIViewController _loadViewFromNibNamed:bundle:] loaded the "QuestionAndAnswerController" nib but the view outlet was not set

  问题: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "QuestionAndAnswerController" nib but the view outlet was not set.'    新创建一个ViewControl

loaded the "XXXView" nib but the view outlet was not set 解决方案

'-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "XXXView" nib but the view outlet was not set.' 查书才知道,没有做nib文件到xxxViewControler程序的关联,特此记录下来: 1, 打开nib文件 2, 点击"File's Owner", 按command+4,设置Class为xxxViewControler 3, 按Control+

loaded the "xxxViewController" nib but the view outlet was not set.'

今天遇到这个问题 loaded the "TestViewController" nib but the view outlet was not set.' 解决办法 点击xib文件的File's Owner 在右边的class文件写上自定义的类 按着ctrl点击File's Owner,将View连接xib文件视图 loaded the "xxxViewController" nib but the view outlet was not set.'

iOS开发出现的错误:loaded the "VCRoot" nib but the view outlet was not set.'

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "VCRoot" nib but the view outlet was not set.' 看下图 iOS开发出现的错误:loaded the "VCRoot" nib b