4

There are a lot of similar questions to this, however I coudn't find exactly my issue.

I created xib file where I placed only one UIView and linked it to my custom class. I also added some components like buttons and labels to this view.

Then I instantiate the view like this:

NSArray* viewsInNib = [[NSBundle mainBundle] loadNibNamed:name owner:self options:nil];
view = [viewsInNib objectAtIndex:0];

And when I'm trying to handle awakeFromNib:

-(void)awakeFromNib
{
    [super awakeFromNib];
    // outlets are nil here
}

I realize that my outlets are nil.

The interesting point is that if I don't use size classes and go with basic option (wAny/hAny) this way works, all outlets are exist and can be used. However when I change the class to some other like iphone option (wCompact, hAny) and launch the app on iphone device, I see that my components, which was created in custom class size are nil in the awakeFromNib method, and after some delay they are all set.

It looks like components wich was added in custom size class are not inited in awakeFromNibmethod, what is quite odd.

I would appreciate if someone can help me with this issue!

Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
  • 1
    The views are not yet initialized in awakeFromNib. Check out this question/answer http://stackoverflow.com/questions/2723042/accessing-view-in-awakefromnib – Yan Nov 16 '14 at 15:11

0 Answers0