开发者

Why is my UIViewController initializer never called?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜