1
votes

I'm trying to modularize a complex UI in several xib's.

I want to programaticly load each additional xib from file.

The xib has controls which are connected to the custom view code.

Then I try to load the xib the following way inside the main view controller:

WIFClientData *clientDataView;

NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"WIFClientData" owner:self options: nil];

clientDataView = [nibViews objectAtIndex:0];
[clientDataView configure];

The problem is that when I try to configure the view:

-(void)configure
{
    self.name.label.text = @"Name";
    self.mobile.label.text = @"Mobile";
}

name and mobile are nil

I currently don't have File's owner connect, or set to any custom class. I only have the view which is layed in the xib, set to the custom class.

I have been reading a lot of things regarding to this but haven't found the answer yet.

Can someone help me?

Nuno

1
could you be more specific on what exactly in the XIB should be connected to IBOutlets in which class? Should all concerned elements be connected to outlets in your viewcontroller or do you have custom UIView subclasses that also expose IBOutlets?Tobi

1 Answers

0
votes

If you have a custom class WIFClientData and set a top-level view's class to WIFClientData in nib (which you then get via [nibViews objectAtIndex:0]), have IBOutlets connected to that view (not to file owner) then this should work. (works for me for custom cells)

Maybe you've misaligned something or mistyped?