转载地址:http://blog.csdn.net/dotneterbj/article/details/6119821
http://blog.csdn.net/leonpengweicn/article/details/6022616
loaded the "MyView" nib but the view outlet was not set错误
当新建一个工程后.经过以下步骤:
1. 在代理类里增加代码一般没有什么难度,看帮助文档就可以做.
2. 主要的步骤是设置MainWindow.xib文件和你的View.xib文件.
MainWindow的Outlet属性里,有两个属性,一个是ViewController,这个要指向你定义的ViewController.
一个是window. 这个一般会指向系统的Window类.
还有一个就是Referencing Outlet: Delegate要指向FileOwner.而MainWindow的File Owner就是UIApplication.
3. 系统模板建立的MainWindow.xib文件里,不包括ViewController,这个需要自己添加一个视图控制类.然后,把这个类的Class指向
你自己增加的ViewController.h.m类.
4.然后自己要再增加一个View.xib,这个文件的File Owner一定要修改,默认的是NSObject.
5. 最为重要的是,每个ViewController都有个内定的View Outlet,这个一定要加进去.否则你会遇到类似一下的错误.
告诉你View Outlet没有设定.就是因为这个.
================================
terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MyView" nib but the view outlet was not set
今天在做练习创建多个视图程序的时候,老是出现下面这样的错误:
p.p1 {margin: 0.0px 0.0px 0.0px 28.0px; text-indent: -28.0px; font: 11.0px Menlo}
'-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "BlueView" nib but the view outlet was not set.'
查书才知道,没有做nib文件到xxxViewControler程序的关联,特此记录下来:
1, 打开nib文件
2, 点击"File's Owner", 按command+4,设置Class为xxxViewControler
3, 按Control+"Files's Owner", 里面有个默认的IBOutlet变量view, 看一下后面有没有做关联,如果没有就拉到下面的View和视图做个关联
【书上出现了缺少这个关联了】;