views:

392

answers:

1

Hi all, I've created a .xib file and added a UIView to it in IB that I've called detailView. I need to load a .xib into the detailView area, and here is the code I'm using in my view controller to do so:

NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"DetailView" 
                                                    owner:self 
                                                  options:nil];
UIView *nibView = [nibObjects objectAtIndex:0];
self.detailView = nibView;

A screenshot of the setup in IB is here: http://www.pict.com/view/2612170/0/screenshot20100123at2

The detailView .xib loads, but for some reason disregards the frame for the detailView area that was set up in IB and fills the whole screen. What gives???

Thanks!

A: 

If I see it right, the detailView outlet is already connected to PropertyEditViewController. You don't want to set self.detailView to nibView manually because you actually override the detailView with its parent view. Just send -loadNibNamed:owner:options: and you should be OK.

Costique
From the view controller, I tried `[self.detailView loadNibNamed:@"DetailView" owner:self options:nil];` and it error'ed out since UIView doesn't respond to -loadNibNamed:owner:options: . What am I missing? Thanks!
Frank Vale
Assuming you call -loadNibNamed:owner:options: from a controller method (that is, self is PropertyEditViewController), the first statement in your original post is legit. I think you don't need the second and third ones because the detailView is already setup in IB. You can replace those two statements with NSLog(@"%@", self.detailView) to make sure we understand each other.
Costique