一、应用的生命周期
二、视图控制器的生命周期
非storyBoard(xib或非xib)都走这个方法
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
}
return self;
}
storyBoard走这个方法
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
if(self = [super initWithCoder:aDecoder])
{
}
return self;
xib加载完成
- (void)awakeFromNib
{
[super awakeFromNib];
}
加载视图,默认从nib
- (void)loadView
{
self.view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.view.backgroundColor = [UIColor redColor];
}
视图控制器中的视图加载完成
- (void)viewDidLoad
{
[super viewDidLoad];
}
视图将要出现
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
view即将布局其Subviews
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
}
view已经布局其Subviews
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
}
视图已经出现
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
视图将要消失
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
视图已经消失
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
出现内存警告
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
视图被销毁
- (void)dealloc
{
}