简体   繁体   中英

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 xib 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 . 替代文字

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM