Looking to understand the iOS UIViewController lifecycle

前端 未结 11 1942
情深已故
情深已故 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:04

    Let's concentrate on methods, which are responsible for the UIViewController's lifecycle:

    • Creation:

      - (void)init

      - (void)initWithNibName:

    • View creation:

      - (BOOL)isViewLoaded

      - (void)loadView

      - (void)viewDidLoad

      - (UIView *)initWithFrame:(CGRect)frame

      - (UIView *)initWithCoder:(NSCoder *)coder

    • Handling of view state changing:

      - (void)viewDidLoad

      - (void)viewWillAppear:(BOOL)animated

      - (void)viewDidAppear:(BOOL)animated

      - (void)viewWillDisappear:(BOOL)animated

      - (void)viewDidDisappear:(BOOL)animated

      - (void)viewDidUnload

    • Memory warning handling:

      - (void)didReceiveMemoryWarning

    • Deallocation

      - (void)viewDidUnload

      - (void)dealloc

    For more information please take a look on UIViewController Class Reference.

提交回复
热议问题