//當(dāng)應(yīng)用程序啟動時(不包括已在后臺的情況下轉(zhuǎn)到前臺),調(diào)用此回調(diào)launchOptions是啟動參數(shù),假如用戶通過點擊push通知啟動的應(yīng)用,這個參數(shù)里會存儲一些push通知的信息。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return YES;
}
//當(dāng)應(yīng)用從活動狀態(tài)主動到非活動狀態(tài)的應(yīng)用程序時會調(diào)用這個方法。這可導(dǎo)致產(chǎn)生某些類型的臨時中斷(如傳入電話呼叫或SMS消息)。或者當(dāng)用戶退出應(yīng)用程 序,它開始過渡到的背景狀態(tài)。使用此方法可以暫停正在進(jìn)行的任務(wù),禁用定時器,降低OpenGL ES的幀速率。游戲應(yīng)該使用這種方法來暫停游戲。
//調(diào)用時機(jī)可能有以下幾種:鎖屏,按HOME鍵,下接狀態(tài)欄,雙擊HOME鍵彈出低欄,等情況。
- (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.
}
//當(dāng)用戶從臺前狀態(tài)轉(zhuǎn)入后臺時,調(diào)用此方法。使用此方法來釋放資源共享,保存用戶數(shù)據(jù),無效計時器,并儲存足夠的應(yīng)用程序狀態(tài)信息的情況下被終止后,將應(yīng)用 程序恢復(fù)到目前的狀態(tài)。如果您的應(yīng)用程序支持后臺運行,這種方法被調(diào)用,否則調(diào)用applicationWillTerminate:用戶退出。
- (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.
}
//當(dāng)應(yīng)用在后臺狀態(tài),將要進(jìn)行動前臺運行狀態(tài)時,會調(diào)用此方法。
//如果應(yīng)用不在后臺狀態(tài),而是直接啟動,則不會回調(diào)此方法。
- (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.
}
//當(dāng)應(yīng)用程序全新啟動,或者在后臺轉(zhuǎn)到前臺,完全激活時,都會調(diào)用這個方法。如果應(yīng)用程序是以前運行在后臺,這時可以選擇刷新用戶界面。
- (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.
}
//當(dāng)應(yīng)用退出,并且進(jìn)程即將結(jié)束時會調(diào)到這個方法,一般很少主動調(diào)到,更多是內(nèi)存不足時是被迫調(diào)到的,我們應(yīng)該在這個方法里做一些數(shù)據(jù)存儲操作。
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
//當(dāng)用戶通過其它應(yīng)用啟動本應(yīng)用時,會回調(diào)這個方法,url參數(shù)是其它應(yīng)用調(diào)用openURL:方法時傳過來的。
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
return nil;
}
AppDelegate中幾個常用的回調(diào)調(diào)用時機(jī)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
推薦閱讀更多精彩內(nèi)容
- http://yanwt.iteye.com/blog/1933932 本篇文章主要介紹一些UIApplicati...
- 本篇文章主要介紹一些UIApplicationDelegate中幾個常用的回調(diào)方法的調(diào)用時機(jī),以幫助你判斷哪些方法...
- 本篇文章主要介紹一些UIApplicationDelegate中幾個常用的回調(diào)方法的調(diào)用時機(jī)。 以幫助你判斷哪些方...
- AppDelegate中幾個常用的回調(diào)調(diào)用時機(jī) ios 本篇文章主要介紹一些UIApplicationDelega...
- 由于AppDelegate中的回調(diào)函數(shù)非常多, 使用起來感覺很混亂, 不知道什么情況該用哪個回調(diào)函數(shù). 于是百度+...