这已然是一个老生常谈的话题,这里再重复记录一下:
<pre>- (instancetype)init{
self= [super init];
if(self) {
debugMethod();
}
return self;
}</pre>
<pre>- (void)loadView{
[super loadView];
debugMethod();
}</pre>
<pre>- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor= [UIColorwhiteColor];
debugMethod();
}</pre>
<pre>- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
debugMethod();
}</pre>
<pre>- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
debugMethod();
}</pre>
<pre>- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
debugMethod();
}</pre>
<pre>- (void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
debugMethod();
}</pre>
打印:
-[NextViewController init]
-[NextViewController loadView]
-[NextViewController viewDidLoad]
-[NextViewController viewWillAppear:]
-[NextViewController viewDidAppear:]
-[NextViewController viewWillDisappear:]
-[NextViewController viewDidDisappear:]