一、控制器View的生命周期:
/*** view加载完毕*/ - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"ICKOneViewController-viewDidLoad"); } /*** view即将显示到window上**/ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; NSLog(@"ICKOneViewController-viewWillAppear"); } /*** view显示完毕(已经显示到窗口)*/ - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; NSLog(@"ICKOneViewController-viewDidAppear"); } /*** view即将从window上移除(即将看不见)**/ - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; NSLog(@"ICKOneViewController-viewWillDisappear"); } /*** view从window上完全移除(完全看不见)**/ - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; NSLog(@"ICKOneViewController-viewDidDisappear"); } -------------------------------------------------------------------------------------------------------------------------------------------------------- /*** view即将销毁的时候调用*/ - (void)viewWillUnload { [super viewWillUnload]; } /*** view销毁完毕的时候调用*/ - (void)viewDidUnload { [super viewDidUnload]; // 由于控制器的view已经不在了,需要显示在view上面的一些数据也不需要 self.apps = nil; self.persons = nil; // // [self.apps release]; // [self.persons release]; } /*** 当接收到内存警告的时候*/ - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; }
二、application的生命周期:
// 1、程序启动完成的时候调用 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSLog(@"%s",__func__); return YES; } // 2、当app失去焦点的时候调用 - (void)applicationWillResignActive:(UIApplication *)application { NSLog(@"%s",__func__); } // 3、app进入后台的时候调用 // app忽然打断的时候,在这里保存一些需要用到的数据 - (void)applicationDidEnterBackground:(UIApplication *)application { NSLog(@"%s",__func__); } // 4、app进入即将前台 - (void)applicationWillEnterForeground:(UIApplication *)application { NSLog(@"%s",__func__); } // 5、当app获取到焦点的时候调用,意味着app可以与用户交互 - (void)applicationDidBecomeActive:(UIApplication *)application { NSLog(@"%s",__func__); } // 6、app被关闭的时候调用 - (void)applicationWillTerminate:(UIApplication *)application { NSLog(@"%s",__func__); } // 7、app接收到内存警告的时候调用 // 清空图片的缓存 - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { NSLog(@"%s",__func__); }