Note that there are some explanatory texts on larger screens.

plurals
  1. POPop a UINavigationController that was presented modally
    primarykey
    data
    text
    <p>I'm working on an iOS 5 application that first presents the user with a Login Window. Upon successful login, a Modal Segue is performed that presents a UINavigationController which contains the bulk of the actual app. Now many things can happen from this point on, but what I'm interested in is when the user decides to log out. </p> <p>I would like to return to the first view, the Login window, but I can't seem to pop the Navigation Controller and return to the first view. </p> <p>As a visualization:</p> <pre><code> (NavigationController) [UserLoginViewController] --modal segue-&gt; [UserMenuTableViewController] --push segue--&gt; [otherviews, etc] ^ | | modal segue | | | v ^ [UserDashBoardViewController] | | | (logout pressed) | | -&lt;---------------pop back to login--------------&lt;- </code></pre> <p>I've tried delegation, to notify the initial login view that it's time to dismiss the Navigation Controller that was presented modally, but I get the error:</p> <pre><code>2012-09-10 11:13:05.749 KITxWebMobileJSONv4[1138:f803] attempt to dismiss modal view controller whose view does not currently appear. self = &lt;UINavigationController: 0x68c6150&gt; modalViewController = &lt;UserDashboardViewController: 0x68d9fb0&gt; 2012-09-10 11:13:05.749 KITxWebMobileJSONv4[1138:f803] attempt to dismiss modal view controller whose view does not currently appear. self = &lt;UserLoginViewController: 0x688ffa0&gt; modalViewController = &lt;UINavigationController: 0x68c6150&gt; </code></pre> <p>The Login View delegation looks like this:</p> <pre><code>// This method is called from the UserMenuTableViewController, when it's time to log out: - (void)userMenuTableViewController:(UserMenuTableViewController *)sender loggedOut:(BOOL)didLogOut { if (didLogOut) { /* delete user info and take care of data on backend: * ... */ // pop navigation controller, presenting the initial Login View: [self dismissModalViewControllerAnimated:YES]; // THIS LINE FIRES AND GETS THE ERROR ABOVE } } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"Login Success"]) { // successful login: // set (UINavigationController *)self.nav to the segue destination (for a handle, if needed): self.nav = (UINavigationController *)segue.destinationViewController; // grab the user menu and set self to be it's delegate: UserMenuTableViewController *userMenu = [self.nav.viewControllers lastObject]; userMenu.delegate = self; } } </code></pre> <p>Thanks in advance! </p>
    singulars
    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.
 

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