Jon
Jon

Reputation: 687

Trying to Get Back to the First UIViewController of the App

I have a app that I am trying to reload the original viewcontroller from the MainViewController. There is no .xib the first view of the app is created in the AppDelegate. After I have loaded a couple UIViewControllers that did other things, I need to return to the original webView (ViewController) that was launched by the app on startup. I am really having a hard time getting anything to work that researched on the web. I just need a way to reload the original view that the app started with. Can anyone provide any possible solutions for me to try please? I am running out of options to try.

Thank!

Upvotes: 0

Views: 95

Answers (1)

LuisEspinoza
LuisEspinoza

Reputation: 8538

You can set the rootViewController again.

In the app delegate use:

self.window.rootViewController = yourFirstViewController;

Good Luck!

EDIT:

Also, you can access to the app delegate globally using:

[[[UIApplication sharedApplication] delegate]

I published a little example project that will help you:

https://github.com/luisespinoza/ChangeViewController

Good Luck!

Upvotes: 2

Related Questions