Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you go from a scene deep within an app's hierarchy back to the beginning?
    primarykey
    data
    text
    <p>I have an app with a storyboard like this: <img src="https://i.stack.imgur.com/hrWAJ.png" alt="enter image description here"></p> <p>The scene labelled as 1 is my applications initial view, the first scene the user sees when they load the app. It's effectively my login/signup scene.</p> <p>The scene labelled as 2 is deep within the app, it's embedded in a UINavigationController which itself is accessed via a UITabBarController. This scene has a Logout button which clears the session and should also return the user to scene #1.</p> <p>What is the proper method for returning back to the first scene? I've tried a few different methods with zero-limited success. Here's what I've tried:</p> <blockquote> <p>[[self navigationController] popToRootViewControllerAnimated:YES];</p> </blockquote> <p>Doesn't do anything as (I believe) when #2 is loaded, it is effectively the root view controller for the current navigationController.</p> <blockquote> <p>Push via segue</p> </blockquote> <p>Doesn't really work as it just adds scene #1 to the stack, enabling the user to go 'back' to the settings. I believe I can hide the navigation bar for this, but from what I can gather, I should not do this as this method just adds the view to the stack and if the user were to repeat this action the app will eventually run out of memory and crash.</p> <blockquote> <p>AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [[delegate.window rootViewController] dismissModalViewControllerAnimated:YES];</p> </blockquote> <p>This does appear to clear everything and return to the initial view, but any interaction with the scene (such as tapping the login or signup button) results in an error such as this:</p> <blockquote> <p>** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target .'</p> </blockquote> <p>I'd greatly appreciated any help you may be able to offer towards solving this. I've been at this for a couple of days, reading through as many SO questions as I could that sounded relevent, attempting to read the Apple documentation (though not really knowing where to start outside of the UINavigationBarController reference) and results from google search.</p> <p>I've only being doing this type of programming for a couple of weeks so I'm sorry if this is a stupid question, I've just been unable to find a successful solution to the problem and it's a bit of a roadblock for me at the moment.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload