Order of UIViewController initialization and loading

后端 未结 5 1437
小鲜肉
小鲜肉 2020-12-12 14:16

I\'m fairly new to UI programming on the Mac and iPhone, and I\'ve run across something that somewhat puzzles me.

A UIViewController has 3 methods that involve the i

5条回答
  •  盖世英雄少女心
    2020-12-12 15:10

    -(void)awakeFromNib
    {
    }
    

    is only called if you are using story board to store the ViewController drawn in story board Nib---means interface bundle.

    the proper sequence is

    -(void)initWithCoder
    -(void)awakefromNib    //(if story board is used)
        or
    -(void)loadView----() //if manually generating the view contoller
    
    -(void)viewDidLoad-----(called only once in the life cycle of viewController)
    -(void)viewWillAppear
    -(void)viewDidAppear
    

    While moving to a new ViewController

    -(void)viewWillDisappear
    -(void)viewDidDisappear
    

    While returning to the first ViewController

    -(void)viewWillAppear
    -(void)viewDidAppear
    

提交回复
热议问题