Looking to understand the iOS UIViewController lifecycle

前端 未结 11 2073
情深已故
情深已故 2020-11-21 22:33

Could you explain me the correct manner to manage the UIViewController lifecycle?

In particular, I would like to know how to use Initialize

11条回答
  •  一整个雨季
    2020-11-21 23:11

    There's a lot of outdated and incomplete information here. For iOS 6 and newer only:

    1. loadView[a]
    2. viewDidLoad[a]
    3. viewWillAppear
    4. viewWillLayoutSubviews is the first time bounds are finalized
    5. viewDidLayoutSubviews
    6. viewDidAppear
    7. * viewWillLayoutSubviews[b]
    8. * viewDidLayoutSubviews[b]

    Footnotes:

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

    (b) May be called an additional 0 or more times.

提交回复
热议问题