我试着做一些复杂的事情,但应该是可能的。所以这里有一个对你们所有专家的挑战(这个论坛是由你们很多人组成的:))。
我正在创建一个问卷“组件”,我想在NavigationContoller
(我的QuestionManagerViewController
)上加载它。“组件”是一个“空的”UIViewController
,它可以根据需要回答的问题加载不同的视图。
我的做法是:
UIView
子类,定义一些IBOutlets
. view对象。Question1View.xib
(这可能是我的问题所在)。我将UIViewController
和UIView
都设置为Question1View类。QuestionManagerViewController
的initWithNib
,看起来像这样:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:@"Question1View" bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
When I run the code, I'm getting this error:
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.'
I'm sure there is a way to load the view using the nib file, without needing to create a viewController class.