1. 程式人生 > >UIViewController函式呼叫順序

UIViewController函式呼叫順序

/*********** 0 執行1次而已 ******************/
+ (void)load {
    NSLog(@" 0:%s", __func__);
}
 
/*********** 1 執行1次而已 ******************/
+ (void)initialize {
    NSLog(@" 1:%s", __func__);
}

/*********** 常規的物件函式 ******************/
/// 2
- (instancetype)init {
    self = [super init];
    if (self) {
        NSLog(@" 2:%s", __func__);
    }
    return self;
}
 
/// 3
- (void)loadView {
    [super loadView];
    NSLog(@" 3:%s", __func__);
}
 
/// 4
- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@" 4:%s", __func__);
}
 
/// 5
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@" 5:%s", __func__);
}
 
/// 6
- (void)updateViewConstraints {
    [super updateViewConstraints];
    NSLog(@" 6:%s", __func__);
}
 
/// 7
- (void)viewWillLayoutSubviews {
    [super viewWillLayoutSubviews];
    NSLog(@" 7:%s", __func__);
}
 
/// 8
- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    NSLog(@" 8:%s", __func__);
}
 
/// 9
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSLog(@" 9:%s", __func__);
}
 
/// 10
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    NSLog(@"10:%s", __func__);
}
 
/// 11
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    NSLog(@"11:%s", __func__);
}