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

  • SEARCH
  • Home
  • 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 9156803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:51:29+00:00 2026-06-17T12:51:29+00:00

I would like to push a view into the navigation controller stack but remove

  • 0

I would like to push a view into the navigation controller stack but remove the current one so when the users press back on the next view it does’t take them to the previous view.

The flow in one direction could be one of these:

View X -> View 1 -> View 2 -> View 3    
View X -> View 1      ->      View 3

But the flow in the oposite direction is always like this:

View X <- View 1      <-      View 3

The problem is that I want to handle it on the View 2 Controller, doing it on the View 3 is easy overriding the back button action. The View 3 can be a lot of different views and I don’t want to override the back button for all of them and check if the previous controller of the stack is the View 2 Controller. They all have the same parent class, so I can’t override the back button for just the ‘View 3 class’ controllers.

I’ve tried this so the controller of the View 2 is not added into the navigation stack:

//Pop controller from stack before pushing
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController pushViewController:controller animated:YES];

But once you pop it removes the view and doesn’t push to the next controller

Other option with the same result

NSMutableArray *viewControllers = [NSMutableArray arrayWithArray: self.navigationController.viewControllers];
[viewControllers removeObjectIdenticalTo:self];
self.navigationController.viewControllers = viewControllers;
[self.navigationController pushViewController:controller animated:YES];
  • 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-17T12:51:30+00:00Added an answer on June 17, 2026 at 12:51 pm

    In regards to your last example that isn’t pushing, does this work?

    NSMutableArray *viewControllers = [NSMutableArray arrayWithArray: self.navigationController.viewControllers];
    [viewControllers removeObjectIdenticalTo:self];
    [viewControllers addObject:controller];
    [self.navigationController setViewControllers: viewControllers animated: YES];
    

    Since you set the controllers to an array of controllers without yourself, you might be setting your navigationController property to nil, making you unable to push the new one immediately after. It doesn’t hurt to try, anyways.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to refresh tk window when I push a button, but I
When a user clicks on a Table View Cell, I would like to push
I would expect that after I push a view controller I then need to
We are developing a Customer feedback application and I would like to push the
I would like to take the memory generated from my struct and push it
I'm diving into iOS development and am getting familiar with navigation view controllers. I'm
Before iOS4, my app's initial view controller would check a passcode on/off settings variable
I would like to pause my app when the iPad receives notifications, like push
My iPhone application has different view controllers and I would like to invoke them
I'm working on a view controller that can be presented modally or pushed into

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.