Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7788993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:09:19+00:00 2026-06-01T21:09:19+00:00

I need to go to the first view in my app. I have a

  • 0

I need to go to the first view in my app. I have a few views pushed onto the stack then a modal navigation controller and more views pushed onto that.

The problem I’m having is that using [[self navigationController] popToRootViewControllerAnimated:YES]; only goes back to the first view in the modal stack.

And I can’t get [[self navigationController] popToViewController:.. to work because the true first view controller isn’t accesible with [[self navigationController] viewControllers].

Any ideas on how to accomplish this? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:09:20+00:00Added an answer on June 1, 2026 at 9:09 pm

    Do this:

    [[self navigationController] dismissModalViewControllerAnimated:YES];
    

    That will get you back to the VC that modally presented the navigation controller. Getting farther back after that depend on how you pushed those “few views” before the navigation controller.

    Edit – explanation to get to the deepest root…

    It sounds like those “few views” are on another, underlying navigation controller’s stack. This can be a little tricky, because the clean way to get farther back in that stack is to have that underlying navigation controller pop to it’s own root. But how can it know that the modal VC on top of it is done?

    Let’s call the view controller that did the modal presentation of second navigation controller VC_a. It’s a modally presented navigation controller whose topmost VC is VC_b. How can VC_a know to pop to it’s navigation root when VC_b modally dismisses itself?

    The good answer (usually) is that VC_b decided to dismiss itself for a reason – some condition in your app/model changed to make it decide to be done.

    We want VC_a to detect this condition, too. When VC_b gets dismissed, and VC_a gets a viewWillAppear message because it’s about to be uncovered:

    // VC_a.m
    
    - (void)viewWillAppear:(BOOL)animated {
    
        [super viewWillAppear:animated];
        if (/* some app condition that's true when VC_b is done */) {
            // I must be appearing because VC_b is done, and I'm being uncovered
            // That means I'm done, too.  So pop...
            [self.navigationController popToRootViewControllerAnimated:NO];
        } else {
            // I must be appearing for the normal reason, because I was just pushed onto the stack
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Navigation Controller with two Views. The First View is a ViewController
I have a super simple app with root view controller and modal view controller.
I have task to make simple app from three Views: in first: UITableView (it
I have an app delegate, whose default view should be preceeded by a modal
I need some help with modal view controllers, as I have not used Modal
So I have two views. One views loads when I start the app. Then
I am building my first mvc3 app. A few questions I have are: 1)
I have made an app in which i am using Two Tabs , First
I have created a Universal app using Interface Builder. My view controllers are embedded
I have a tab bar + navigation based app and I'd like to launch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.