iOS開發-生命週期
iOS開發-生命週期
應用生命週期
首次啟動Not running→Inactive→Active
呼叫didFinishLaunchingWithOptions,applicationDidBecomeActive
應用結束Active → Inactive → Background→Suspended→Not running
呼叫applicationWillResignActive,applicationDidEnterBackground,applicationWillTerminate
應用重新執行Suspended → Background → Inactive → Active
呼叫applicationWillEnterForeground,applicationDidBecomeActive
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
NSLog(@"%@",@"didFinishLaunchingWithOptions");
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
NSLog(@"%@",@"applicationWillResignActive");
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
NSLog(@"%@",@"applicationDidEnterBackground");
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
NSLog(@"%@",@"applicationWillEnterForeground");
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
NSLog(@"%@",@"applicationDidBecomeActive");
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
NSLog(@"%@",@"applicationWillTerminate");
}
檢視生命週期
// 檢視建立
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"%@",@"viewDidLoad");
}
// 檢視即將可見
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"%@",@"viewWillAppear");
}
// 檢視已經可見
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSLog(@"%@",@"viewDidAppear");
}
// 檢視即將不可見
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
NSLog(@"%@",@"viewWillDisappear");
}
// 檢視已經不可見
- (void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
NSLog(@"%@",@"viewDidDisappear");
}
// 低記憶體警告
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
NSLog(@"%@",@"didReceiveMemoryWarning");
}
// 檢視銷燬
- (void)viewDidUnload{
[super viewDidUnload];
NSLog(@"%@",@"viewDidUnload");
}
相關文章
- iOS開發筆記(九):UIViewController的生命週期iOS筆記UIViewController
- iOS APP的生命週期iOSAPP
- iOS開發之UIView與UIViewController的生命週期總結iOSUIViewController
- iOS開發-檢視與檢視控制器生命週期iOS
- 開發方法---軟體生命週期
- mpvue小程式開發 - 生命週期梳理Vue
- iOS 生命週期的缺失和錯亂iOS
- 安全軟體開發生命週期簡介
- 軟體開發的生命週期過程
- iOS 檢視控制器的生命週期iOS
- iOS執行緒生命週期的監控iOS執行緒
- 生命週期
- iOS初級開發學習筆記:APP生命週期的學習總結iOS筆記APP
- Java開發學習(五)----bean的生命週期JavaBean
- View生命週期與Activity生命週期的關係View
- iOS-APP的啟動流程和生命週期iOSAPP
- vue - 生命週期Vue
- Fragment生命週期Fragment
- vue生命週期Vue
- spring生命週期Spring
- ubuntu生命週期Ubuntu
- Flutter - 生命週期Flutter
- sessionStorag 生命週期Session
- PHP 生命週期PHP
- maven生命週期Maven
- Activity生命週期
- React生命週期React
- Salesforce 生命週期管理(一)應用生命週期淺談Salesforce
- 04 - 06 Flutter開發初體驗 & Widget 生命週期Flutter
- Vue前後端互動、生命週期、元件化開發Vue後端元件化
- vue 生命週期梳理Vue
- java servlet 生命週期JavaServlet
- Android Activity生命週期Android
- Activity生命週期onDestroy
- React-生命週期React
- IOC與生命週期
- vue 生命週期深入Vue
- React元件生命週期React元件
- JPA概述、生命週期