[UIApplicationDelegate的生命周期]
1.进入应用:
应用程序的入口,从应用生命周期开始到结束只调用一次
didFinishLaunchingWithOptions :完成加载后
applicationDidBecomeActive :进入活跃状态
2.退回到后台:
applicationWillResignActive : 取消活跃
applicationDidEnterBackground:进入后台
3.从后台返回前台
applicationWillEnterForeground:即将进入前台
applicationDidBecomeActive:应用活跃
4.退出
applicationWillResignActive :取消活跃
applicationDidEnterBackground:进入后台
applicationWillTerminate:退出
操作顺序是:先打开软件(1,5),再使软件到后台(2,3),再进入前台(4,5),再command+shift+2下h键退出程序[取消活跃,进入后台,退出程序] (2,3,6)
viewController的生命周期
1.第一次进入界面
加载视图 -(void)loadView
视图已经加载 -(void)viewDidLoad
视图将要出现 -(void)viewWillAppear:(BOOL)animated
视图已经出现 -(void)viewDidAppear:(BOOL)animated
2.退出当前界面
视图即将消失 -(void)viewWillDisappear:(BOOL)animated
视图已经消失 -(void)viewDidDisappear:(BOOL)animated
3.返回当前界面
视图将要出现 -(void)viewWillAppear:(BOOL)animated
视图已经出现 -(void)viewDidAppear:(BOOL)animated
加载一个页面,推送到下一个页面再返回上一个界面
2015-08-06 21:07:36.694 UIViewControllerLifeLoop[7634:90b] 加载视图:loadView
2015-08-06 21:07:36.696 UIViewControllerLifeLoop[7634:90b] 视图已经加载:viewDidLoad
2015-08-06 21:07:36.700 UIViewControllerLifeLoop[7634:90b] 视图将要出现:viewWillAppear
2015-08-06 21:07:36.711 UIViewControllerLifeLoop[7634:90b] 视图已经出现:viewDidAppear
2015-08-06 21:07:48.798 UIViewControllerLifeLoop[7634:90b] 视图即将消失:viewWillDisappear
2015-08-06 21:07:49.317 UIViewControllerLifeLoop[7634:90b] 视图已经消失:viewDidDisappear
2015-08-06 21:07:51.036 UIViewControllerLifeLoop[7634:90b] 视图将要出现:viewWillAppear
2015-08-06 21:07:51.546 UIViewControllerLifeLoop[7634:90b] 视图已经出现:viewDidAppear
第一页隐藏导航栏,第二页显示导航栏
-(void)viewWillAppear:(BOOL)animated{
// 将要出现时隐藏
// 界面大都在 WillAppear中,数据在 DidDisappear
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
}
-(void)viewDidDisappear:(BOOL)animated{
// 已经消失的时候导航栏出现
// 已经消失显示导航栏
[super viewDidDisappear:animated];
self.navigationController.navigationBarHidden = NO;
}