I get used to put either of viewWillAppear and viewDidLoad, it’s OK until know. However I’m thinking there should be some rules that guide when to put into viewWillAppear and when to put into viewDidLoad?
I get used to put either of viewWillAppear and viewDidLoad , it’s OK until
Share
Simple rule I use is this.
viewDidLoadis when the view’s resources are loaded. The view is not drawn onscreen yet. So calculations and code dealing with the geometry and visuals of the view should not be put here. They should be in theviewWillAppearorviewDidAppearmethod.Also viewWillAppear can be called multiple times
For these reason,
viewWillAppearshould not contain codes that takes longer to finish. (at least the code running on the main thread). Neither should codes that only needs to be run once per view display.There are more I am sure but these are simple to remember and I hope it helps.