When to enter in viewWillAppear and when to enter in viewDidLoad?

I'm used to putting any of viewWillAppearand viewDidLoad, it's normal until you find out. However, I think there should be some rules that determine when to put in viewWillAppearand when to put in viewDidLoad?

+5
source share
2 answers

The simple rule that I use is this. viewDidLoad- this is when presentation resources are loaded. No image has been drawn yet. Therefore, calculations and code regarding geometry and visual representations should not be specified here. They must be in the viewWillAppearor method viewDidAppear.

ViewWillAppear can also be called multiple times

  • /
  • / /uiactivityController.

viewWillAppear , . ( , ). , .

, , , , .

+11

viewDidLoad: .

viewWillAppear:

viewDidLoad - , . viewWillAppear , . , viewDidLoad - , UILabel. , , , , , iPod , "Now Playing", .

, , . viewDidLoad viewWillAppear, , - , . , . , ( - ?), . , , Twitter. , Twitterrific, "..." , .

+4

All Articles