如何使用附加的视图控制器加载xib文件? [英] How to load xib file with attached view controller?
问题描述
我正在使用xib文件作为Coverflow组件中的后视图.而且看起来很好.
I am using a xib file as a back view in coverflow component . and it is seeing nicely .
用于加载xib文件的代码是:
The code for loading a xib file is :
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"TestMine" owner:nil options:nil];
backView = [array objectAtIndex:0];
现在,我想在不更改当前代码的情况下将此视图控制器附加到视图控制器.
Now I want to attach a view controller with this xib without changing the current code .
我该怎么办?
我收到错误消息:Exception :*** -[UIViewController superview]: unrecognized selector sent to instance 0x5891120
如果需要更多详细信息回答这个问题,请告诉我.
Tell me if more details need to answer the question .
谢谢.
推荐答案
我不太了解您的问题.似乎您想以该xib实例化视图控制器?
I don't exactly understand your question. It seems like you want to instantiate a view controller with this xib as the view?
您可以这样做:
[[UIViewController alloc] initWithNibName:@"TestMine" bundle:nil];
您应该继承UIViewController以便继承IBOutlets和IBAction. 确保将视图控制器设置为文件的所有者,并连接文件的出口.
You should subclass UIViewController in order to hook up IBOutlets and IBActions. Make sure you set the view controller as the file's owner and hook up it's outlets.
这篇关于如何使用附加的视图控制器加载xib文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!