国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

IOS控件的生命周期

2019-11-14 20:15:35
字體:
來源:轉載
供稿:網友

ViewController的生命周期包括: 
Initialize 
ViewDidLoad 
ViewWillAppear 
ViewDidAppear 
ViewWillDisappear 
ViewDidDisappear 
ViewDidUnload 
Dispose 

      對于application來說,ViewController的每個階段都對應了一個方法,IOS會在適當的時間調用對應的方法,因此,我們可以在每個方法中添加對應的代碼來做我們想做的事。需要注意的是,這些方法都是為ViewController服務的,對于Views對象來說,是沒有這些方法的。 
       View的生命周期方法如下: 

   * ViewDidLoad - Called when you create the class and load from xib. Great for initial setup and one-time-only work 

   * ViewWillAppear - Called right before your view appears, good for hiding/showing fields or any Operations that you want to happen every time before the view is visible. Because you might be going back and forth between views, this will be called every time your view is about to appear on the screen 

   * ViewDidAppear - Called after the view appears - great place to start an animations or the loading of external data from an API. 

   * ViewWill/DidDisappear - Same idea as the WillAppear. 

   * ViewDidUnload/Dispose - Available to you,  In objective-c, this is where you do your cleanup and release of stuff, but this is handled automatically so not much you really need to do here. 

Application的生命周期包括: 
      在IOS中,生命周期就是由一系列的方法構成, 對于一個App來說,涉及到的生命周期有: 
1、點擊icon啟動,對應的方法有: 
      didFinishLaunchingWithOptions: 
      applicationDidBecomeActive: 
2、按下Home鍵,返回桌面,對應方法: 
      applicationWillResignActive 
      applicationDidBecomeInactive 
3、再點擊icon回到前臺,對應方法: 
      applicationWillEnterForegroud 
      applicationDidBecomeActive 
4、Application忽然被終止,對應方法: 
     applicationWillTerminate 
     這兒需要注意,點2下home鍵,把后臺程序關掉不會調用這個方法,在蘋果的IOS開發指南上有如下描述: 
”Even if you develop your application using iphone SDK 4 and later, you must still be PRepared for your application to be terminated. If memory becomes constrained, the system might remove applications from memory in order to make more room. If your application is currently suspended, the system removes your application from memory without any notice. However, if your application is currently running in the background, the system does call the applicationWillTerminate:method of the application delegate. Your application cannot request additional background execution time from this method.“ 就是說,在機器內存不足時,IOS會清理后臺程序,在這個時候會調用該方法,一般情況下,很少會用到這個方法,盡量不要在這個方法里寫你的應用邏輯。 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鹿邑县| 兰州市| 余干县| 辰溪县| 固始县| 巩义市| 枣庄市| 江山市| 贡觉县| 襄垣县| 咸丰县| 庆云县| 剑河县| 武山县| 武定县| 奉节县| 茂名市| 昭觉县| 那坡县| 肃南| 梓潼县| 威宁| 沅陵县| 青州市| 黔东| 金堂县| 屏山县| 永城市| 江源县| 多伦县| 拜泉县| 武义县| 永定县| 连江县| 临颍县| 宜昌市| 淳化县| 永泰县| 忻城县| 丘北县| 曲靖市|