BennoDual
BennoDual

Reputation: 6259

Which event is called after the view is shown

I have created a small app with a storyboard. Now, I have created a first view, which should be my splash. I am now searching for the right place to put my work into it. After this work, I would programmatically triggering a Storyboard Segue to switch to the next view. For this, I am searching the right place/event. It should be an event which is called right after the view will be shown.

I have tried viewDidLoad but it seems, that this event is triggered before the view is shown on the screen.

Upvotes: 1

Views: 98

Answers (2)

OursementVotre
OursementVotre

Reputation: 116

Actually, and for a little nitpicking here. viewDidAppear is not called every time a VC is shown, but each time it is inserted in the VC hierarchy. So it seems to be what you want to use for now. But if you have later some use case where you want some action to take place each time the view is displayed to the user you need other means. For example this method will not be called when you push back some navigation VC (your VC is already in the hierarchy).

Upvotes: 0

Lucien
Lucien

Reputation: 451

The (void)viewDidLoad method is called the 1st time the view is loaded.

So it's the good place where to write your init/setup lines.

The (void)viewDidAppear: method is called everytime your view is displayed.

Hope this helps.

Upvotes: 1

Related Questions