ios開發(fā)筆記-關(guān)于UIApplication(下)代理 AppDelegate

這個(gè)系列主要寫一些平時(shí)ios開發(fā)和學(xué)習(xí)過程中所記錄的問題、隨筆和解決方法,我會(huì)盡量用更多的截圖或者gif圖來還原我的開發(fā)現(xiàn)場,在執(zhí)行個(gè)人備忘錄功能的同時(shí)希望對(duì)你有所幫助。

1.背景

移動(dòng)操作系統(tǒng)的app容易受到來電或者鎖屏等干擾,在app受到干擾時(shí)會(huì)產(chǎn)生一些系統(tǒng)事件,這時(shí)UIApplication會(huì)通知它的delegate對(duì)象,讓代理來處理這些系統(tǒng)事件

2.AppDelegate方法含義

//1.應(yīng)用程序啟動(dòng)完畢時(shí)調(diào)用

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

? ? // Override point for customization after application launch.

? ? return YES;

}

//2.應(yīng)用程序?qū)⒁ソ裹c(diǎn)時(shí)調(diào)用

- (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 invalidate graphics rendering callbacks. Games should use this method to pause the game.

}

//3.應(yīng)用程序進(jìn)入后臺(tái)時(shí)調(diào)用

- (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.

}

//4.應(yīng)用程序進(jìn)入前臺(tái)時(shí)調(diào)用

- (void)applicationWillEnterForeground:(UIApplication *)application {

? ? // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.

}

//5.應(yīng)用程序獲取焦點(diǎn)

- (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.

}

//6.應(yīng)用程序退出時(shí)調(diào)用

- (void)applicationWillTerminate:(UIApplication *)application {

? ? // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

}

注意:失去焦點(diǎn)的意思是不能與用戶進(jìn)行交互



?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,545評(píng)論 19 139
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,653評(píng)論 5 6
  • 通過這兩次的聽讀,對(duì)我教學(xué)上有很大的幫助,我有一下幾個(gè)感受: 1.再現(xiàn)、用符號(hào)表現(xiàn)以往經(jīng)驗(yàn)的人類與生具來的能力從2...
    janemona婷婷閱讀 401評(píng)論 0 0
  • 2018年2月7日 星期三 晴 今天要去姥娘家,哥哥可興奮了,上午9:20出發(fā),從東營到泰安用...
    家有茟霖閱讀 270評(píng)論 2 1
  • 一、學(xué)習(xí)目標(biāo) 1、了解朦朧詩特點(diǎn)。 2、培養(yǎng)解讀詩歌意象的能力。 3、樹立正確的愛情觀。 二、導(dǎo)入新課 愛...
    雙燕歸來閱讀 2,320評(píng)論 0 2

友情鏈接更多精彩內(nèi)容