About viewController's “viewDidLoad” and “viewWillAppear” methods

后端 未结 5 888
轻奢々
轻奢々 2020-12-09 07:02

I\'ve got a question regarding the two mentioned methods, since in my tests I don´t make clear the order they are called. I thought that, firstly, viewDidLoad i

5条回答
  •  遥遥无期
    2020-12-09 07:19

    As you said, ViewDidLoad is only calling once after loading the view. So we can initialize the instances in the viewDidLoad. It is mainly meant for the initialization.

    viewWillAppear will invoke whenever we reach to this view. So if there is any changes in UI, we can done it in viewWillAppear.

提交回复
热议问题