Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the viewdidload method get called before the view appear?

Tags:

ios

I've started learning IOS, I'm wondering does the viewdidload: method get called before the view appears on screen? The apple developer guide says this method gets called after the view is loaded into memory but I don't understand What "loaded into memory" means, does it mean the view doesn't appear on screen?

like image 207
hello_java Avatar asked Aug 12 '14 17:08

hello_java


People also ask

Does viewDidLoad get called before viewWillAppear?

Always called after viewDidLoad (for obvious reasons, if you think about it), and just before the view appears on the screen to the user, viewWillAppear is called. This gives you a chance to do any last-minute view setup, kick off a network request (in another class, of course), or refresh the screen.

Which is called first viewDidLoad or viewDidAppear?

viewDidLoad is called once when the controller is created and viewDidAppear is called each time the view, well, DID appear. So say you have a modal view that you present, when that view is dismissed, viewDidAppear will be called, and viewDidLoad will not be called.

How often is viewDidLoad called?

viewDidLoad() is one of the initialization methods that is called on the initial view controller. viewDidLoad() is called before anything is shown to the user - and it is called only once.

Is viewDidLoad called once?

viewDidLoad method is called only once in ViewController lifecycle. The reason retrieveMessage() is called in viewDidLoad because it's adding observer to start listening for received and sent message.


1 Answers

Does the viewdidload method get called before the view appears?

Yes.

Borrowed from this answer, view controller delegate method order is:

- (void)loadView;
- (void)viewDidLoad;
- (void)viewWillAppear;
- (void)viewDidAppear;

What "loaded into memory" means?

It means when the object (view) is created. It is possible to create and show a view virtually at the same time. However, technically viewDidLoad will be called first.

like image 142
Jason McCreary Avatar answered Oct 14 '22 03:10

Jason McCreary