Jayson Tamayo Jayson Tamayo - 2 months ago 17
Swift Question

How to know if ViewController is visible again

How do I know if the ViewController is visible again?

I tried putting the

print
command inside
viewDidAppear
. Run the app. Press the home button. Return to the app but
viewDidAppera
dont get executed.

i am trying to execute a code right after the app becomes visible again.

How do I do that?

Answer

Use your print statement in the AppDelegate for application: WillEnterForeground OR application: didBecomeActive both of those are called at different times when the user returns to the application. Use one or the other depending on at what point you'd like to call or reference your code