控制器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->viewWillLayoutSubviews->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
子控制器的viewDidLoad 方法, 是在父控制器 的 willappear 方法 调用的
before -----[NewsViewController viewWillAppear:]
子控制器的-[TopLineViewController viewDidLoad]
after ----[NewsViewController viewWillAppear:]