如何使用附加的视图控制器加载xib文件?

har*_*alb 9 iphone xib uiviewcontroller

我使用xib文件作为coverflow组件中的后视图.它很好看.

加载xib文件的代码是:

NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"TestMine" owner:nil options:nil];
        backView = [array objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud)

现在我想在不更改当前代码的情况下使用此xib附加视图控制器.

我怎么能这样做?

我收到错误: Exception :*** -[UIViewController superview]: unrecognized selector sent to instance 0x5891120

如果有更多细节需要回答这个问题,请告诉我.

谢谢 . alt text http://img265.imageshack.us/img265/8151/ssstack.png

Ren*_*ers 19

我不完全理解你的问题.看起来你想用这个xib作为视图来实例化一个视图控制器?

你可以这样做:

[[UIViewController alloc] initWithNibName:@"TestMine" bundle:nil];
Run Code Online (Sandbox Code Playgroud)

你应该继承UIViewController,以便连接IBOutlets和IBActions.确保将视图控制器设置为文件的所有者并连接它的出口.