Loading custom UIView from nib, all subviews contained in nib are nil?

前端 未结 2 1807
一生所求
一生所求 2020-12-07 16:06

I have a custom UIView object with a nib that defines the view/subview layout. My outlets are connected, and when I init the object from ini

2条回答
  •  天涯浪人
    2020-12-07 16:25

    Check that you are calling the 'super' implementation of initWithCoder: and awakeFromNib in each of your overridden methods i.e.

    - (id)initWithCoder:(NSCoder *)decoder {
        if ((self = [super initWithCoder:decoder])) {
          ...your init code...
        }
        return self;
    }
    
    - (void)awakeFromNib {
         [super awakeFromNib];
         ...your init code...
    }
    

提交回复
热议问题