控制器的生命周期
- 也就是控制器view的生命周期
// 自定义控制器view,这个方法只有实现了才会执行 - (void)loadView { self.view = [[UIView alloc] init]; self.view.backgroundColor = [UIColor orangeColor]; } // view是懒加载,只要view加载完毕就调用这个方法 - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"%s",__func__); } // view即将显示 - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; NSLog(@"%s",__func__); } // view即将开始布局子控件 - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; NSLog(@"%s",__func__); } // view已经完成子控件的布局 - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; NSLog(@"%s",__func__); } // view已经出现 - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; NSLog(@"%s",__func__); } // view即将消失 - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; NSLog(@"%s",__func__); } // view已经消失 - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; NSLog(@"%s",__func__); } // 收到内存警告 - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; NSLog(@"%s",__func__); } // 方法已过期,即将销毁view - (void)viewWillUnload { } // 方法已过期,已经销毁view - (void)viewDidUnload { }