1. 程式人生 > >00 - 控制器view生命週期

00 - 控制器view生命週期

00 - 控制器view生命週期

控制器View的生命週期方法:只要是控制器的生命週期方法,都是以view開頭.

控制器View載入完成時呼叫

- (void)viewDidLoad {

     [super viewDidLoad];

}

控制器的View顯示完成時呼叫

-(void)viewDidAppear:(BOOL)animated{

[super viewDidAppear:animated];

}

控制器的View即將顯示的時候呼叫

-(void)viewWillAppear:(BOOL)animated{

[super viewWillAppear:animated];

}

控制器的View完全消失的時候呼叫

-(void)viewDidDisappear:(BOOL)animated{

[super viewDidDisappear:animated];

}

控制器的View即將消失的時候呼叫.

-(void)viewWillDisappear:(BOOL)animated{

[super viewWillDisappear:animated];

}

佈局控制器View的子控制元件完成時呼叫

-(void)viewDidLayoutSubviews{

[super viewDidLayoutSubviews];

}

將要佈局控制器的View裡面子控制元件的時候就會呼叫.

-(void)viewWillLayoutSubviews{

[super viewWillLayoutSubviews];

}

ARC的生命週期

viewDidLoad->viewWillAppear->viewDidLayoutSubviews->viewDidLayoutSubviews->viewDidAppear->

viewWillDisappear->viewDidDisappear

在非ARC當中.

當前控制器的View即將被銷燬的時候會呼叫

-(void)viewWillUnload{

[super viewWillUnload];

}

當前控制器的View被銷燬的時候會呼叫

-(void)viewDidUnload{

[super viewDidUnload];

     清空介面上的資料.

     self.dataList = nil;

}

viewDidLoad->viewWillAppear->viewDidLayoutSubviews->viewDidLayoutSubviews->viewDidAppear->

viewWillDisappear->viewDidDisappear->接收到記憶體警告->viewWillUnload->釋放View->viewDidUnload

簡書地址:http://www.jianshu.com/users/227bbeb09f91/latest_articles