开发者

Why is my UIViewController initializer never called?

开发者 https://www.devze.com 2022-12-26 06:30 出处:网络
I made a view-based project from a fresh template. There\'s a UIViewController which is created with an XIB.

I made a view-based project from a fresh template. There's a UIViewController which is created with an XIB.

In the implementation I uncommented that and added an NSLog. But this is never called:

// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
        NSLog(@"nib");
    }
    return self;
}

since that is 开发者_开发知识库initialized from a nib / xib, that should be called for sure, right? however, it doesn't. I do get an NSLog message when I put that in viewDidLoad.


When an object is initialized from nib/xib, the -initWithCoder: method will be used for initialization.

-initWithNibName:… is never used in unarchiving.

0

精彩评论

暂无评论...
验证码 换一张
取 消