开发者

How to load xib file with attached view controller?

I am using a xib file as a back view in coverflow component . and it is seeing nicely .

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 x开发者_运维知识库ib without changing the current code .

How can I do so ?

I am getting the error : Exception :*** -[UIViewController superview]: unrecognized selector sent to instance 0x5891120

Tell me if more details need to answer the question .

Thanks .

How to load xib file with attached view controller?


I don't exactly understand your question. It seems like you want to instantiate a view controller with this xib as the view?

You can do that like this:

[[UIViewController alloc] initWithNibName:@"TestMine" bundle:nil];

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜