When and why to use initWithNibName:bundle: in dev

2019-08-24 15:28发布

问题:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

Why we use this method? Is it necessary when using xib file?

回答1:

Why we use init with nib ?

So we can take a view created with interface builder and initialize a view from that instead of coding everything yourself.

it is a good alternative to coding everything if you just need basic things.