Search code examples
iosios5uiapplicationdelegate

Show initial view every time the app launches


For security reasons I need the user to log in each time my app is opened. What I would like to do is when the app is about to close reset it to the initial view. I know from a view controller I can use the following code:

[[self navigationController] popToRootViewControllerAnimated:NO];

I'm not sure how to adapt that to work from the app delegate.

On the initial view I have it set to show the login modal on viewDidLoad. That seems to only fire the first time, and not in the app when using the back button, so I'm hoping I'm safe using this method to show the login screen.

For clarification, I understand I will do this in the app delegate, I'm looking for the specific bit of code I can use to tell the app to reset the views.


Solution

  • An easy solution to this could be to stop your app from running in the background. This would completely shut down your app when the user closes it.

    I believe to do this you just go to info.plist of your project and check "Application does not run in background" to YES.

    Good luck! Hope that helps.