Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 . alt text

like image 767
harshalb Avatar asked May 13 '10 08:05

harshalb


1 Answers

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.

like image 116
Rengers Avatar answered Oct 17 '22 18:10

Rengers