user3051755 user3051755 - 1 year ago 75
iOS Question

iOS equivalent for onRestart()

What is the iOS equivalent for

used on Android?

is called when current activity is being re-displayed to the user (the user has navigated back to it).

Answer Source

I believe you need viewWillAppear method:

override func viewWillAppear(_ animated: Bool) {
    //your code here

It is called every time right before view is going to be shown. So it will be called when view is shown for the first time as well. If you want to avoid running your code for the first time viewWillAppear is called, you will have to add a flag property and check if it has been set previously.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download