我正在尝试做一些有点复杂但应该可行的事情。所以这里向所有专家们发出挑战(这个论坛上有很多你们 : ) )。
我正在创建一个“问卷”组件,我想在NavigationContoller
上加载它(我的QuestionManagerViewController
)。这个“组件”是一个“空”的UIViewController
,根据需要回答的问题可以加载不同的视图。
我正在这样做:
- 创建Question1View对象作为
UIView
子类,并定义一些IBOutlets
。 - 创建(使用界面构建器)
Question1View.xib
(这可能是我的问题所在)。我将UIViewController
和UIView
都设置为Question1View类。 - 我使用IB将输出链接到视图的组件。
我重写了我的
QuestionManagerViewController
的initWithNib
,使它看起来像这样:
当我运行代码时,出现了以下错误信息:- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:@"Question1View" bundle:nibBundleOrNil]) { // Custom initialization } return self; }
2009-05-14 15:05:37.152 iMobiDines[17148:20b] *** Terminating app due to uncaught exception '
NSInternalInconsistencyException
', reason: '-[UIViewController _loadViewFromNibNamed:bundle:]
loaded the "Question1View" nib but the view outlet was not set.'
我确信有一种方法可以使用nib文件加载视图,而不需要创建viewController类。