Order of UIViewController initialization and loading

后端 未结 5 1424
小鲜肉
小鲜肉 2020-12-12 14:16

I\'m fairly new to UI programming on the Mac and iPhone, and I\'ve run across something that somewhat puzzles me.

A UIViewController has 3 methods that involve the i

5条回答
  •  情歌与酒
    2020-12-12 15:18

    The initWithNibName:bundle: method is the designated initializer for the UIViewController class.

    Try overriding and using it instead of init:

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

    ...

    UIViewControllerSubClass *someViewController = [[UIViewControllerSubclass alloc] initWithNibName:@"UIViewControllerSubclass" bundle:nil];
    

提交回复
热议问题