views:

271

answers:

1

Hello all ,

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

+1  A: 

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.

Rengers
Sorry that you misunderstood the question . The question is I am just loading the nib with the above code and I have shown in the picture the viewcontroller in the xib file . so I am asking that whether the viewcontroller in that xib can handle that view with just above code of loading the xib file from mainBundle
hib