Viewcontroller的生命周期

这已然是一个老生常谈的话题,这里再重复记录一下:


Viewcontroller的生命周期_第1张图片
Viewcontroller生命周期

- (instancetype)init{
self= [super init];
if(self) {
debugMethod();
}
return self;
}

- (void)loadView{
[super loadView];
debugMethod();
}

- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor= [UIColorwhiteColor];
debugMethod();
}

- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
debugMethod();
}

- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
debugMethod();
}

- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
debugMethod();
}

- (void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
debugMethod();
}

打印:

-[NextViewController init]

-[NextViewController loadView]

-[NextViewController viewDidLoad]

-[NextViewController viewWillAppear:]

-[NextViewController viewDidAppear:]

-[NextViewController viewWillDisappear:]

-[NextViewController viewDidDisappear:]

你可能感兴趣的:(Viewcontroller的生命周期)