Question

I want my app to go back to the login screen (Which is the root view in the navigation Controller) when it goes inactive.

I'm in applicationWillResignActive and appdelegate.m does not recognize self.navigationController

I tried to make an outlet or the navigation contller in appdelegate.h using ctrl drag in storyboard but it wouldn't let me.

So does anyone know how to get it to switch to a specific view when it goes inactive?

Was it helpful?

Solution

You could just display the original uiviewcontroller when your app comes back by doing that code in the method applicationWillEnterForeground or applicationDidBecomeActive

quick code

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
    [navigationController popToRootViewControllerAnimated:YES];
}

I am sure not the only or best way to do it but it technically works

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top