iOS[Swift] -- Life cycle of UIViewContorller

uiviewcontroller_lifecycle

平時在講ViewController的生命周期時,我們只大多只關(guān)注以下六個方法:

  • viewDidLoad
    *viewWillAppear
  • viewDidAppear
  • viewWillDisappear
  • viewDidDisappear
  • viewDidUnload

其實ViewController的生命周期如下:

  • loadView[1]
  • viewDidLoad[1]
  • viewWillAppear
  • viewWillLayoutSubviews [2]

    Called to notify the view controller that its view is about to layout its subviews.

  • viewDidLayoutSubviews[2]

Called to notify the view controller that its view has just laid out its subviews.

  • viewDidAppear
  • viewWillLayoutSubviews
  • viewDidLayoutSubviews
  • viewWillDisappear
  • viewDidDisappear
  • viewDidUnload

  1. If you manually nil out your view during didReceiveMemoryWarning, loadView and viewDidLoad will be called again. That is, by default loadView and viewDidLoad only gets called once per view controller instance. ? ?

  2. May be called an additional 0 or more times .viewWillLayoutSubviews and viewDidLayoutSubviews will also be called at other times when subviews of the main view are loaded, for example when cells of a table view or collection view are loaded. ? ?

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

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

  • 172.簡述視圖控制器的生命周期。 1)init函數(shù)(init;initWithFrame;initWithCod...
    AlanGe閱讀 470評論 0 0
  • 27、ViewController的didReceiveMemoryWarning是在什么時候調(diào)用的?默認(rèn)的操作是...
    煙雨平生花飛舞閱讀 694評論 0 1
  • 一、 大體流程: (loadView/nib)文件來加載view到內(nèi)存-->viewDidLoad函數(shù)進(jìn)一步初始化...
    willphonez閱讀 11,396評論 2 8
  • ViewController是IOS開發(fā)中MVC模式中的C,ViewController是view的con...
    豆瓣菜閱讀 4,254評論 0 15
  • 傳統(tǒng)的單純采用指數(shù)增長的慢啟動算法有一個無法避免的問題,在臨界進(jìn)入擁塞避免階段時,特別是在高帶寬長距離網(wǎng)絡(luò)中,容易...
    Allenkevin閱讀 2,616評論 5 0

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