I want to execute code before view appears but viewDidLoad
is getting called before viewWillAppear
. Why is it so??
ViewDidLoad is called when the view is loaded in to memory. i.e if you are using storyboard, the app has unarchived the view and loaded it into memory(not yet on screen).
When the app is ready to load the view on the screen it will call the viewWillAppear method.
In your case, if you want to execute code before the view appears on screen, you could add it in either viewDidLoad or viewWillAppear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With