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 9150981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:41:23+00:00 2026-06-17T11:41:23+00:00

I’ve got a little problem on navigating through my views. Here is my configuration

  • 0

I’ve got a little problem on navigating through my views.
Here is my configuration :
Ive got 1 Tabbar Controller with 2 relationship segues to 2 simple views embedded inside a navigation controller.
Now i want to navigate from view controller 1 to view controller 3 and i also want to show the correct tab selected inside the tabbar. And if i come from view controller 1, i also want that the back button redirects me the the previous tab. I tried something with a segue connected between that views, but if i do so, it just pushes the view controller onto the navigation stack but not changes the tab. So my question now is, what is the best way of managing this Problem

Screenshot:

enter image description here

  • 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-17T11:41:24+00:00Added an answer on June 17, 2026 at 11:41 am

    Here’s a way to do it. But I’m posting this really to illustrate why you shouldn’t do it.

    • I’m using VC2’s and VC3’s view tag property to pass navigation data around, which has the effect of tightly coupling all three objects.
    • I override back bar button for the VC1->VC3 context. You lose consistency.
    • VC3->VC2 provides back animation. VC3->VC1 has no animation as it flips from one tab to another. More inconsistency
    • VC1->VC3, tap Tab Item 2 transitions to VC2. UI confusion.

    Anyway if you still want to do this…
    .

    ViewController1
    Has a “jump to VC3” button, wire up to jumpToVC3:

     //ViewController1.m
    
    #import "ViewController1.h"
    
    @implementation ViewController1
    
    - (IBAction)jumpToVC3:(id)sender {
        NSArray* viewArray = [[[self.tabBarController viewControllers] objectAtIndex:1] viewControllers];
        [[[viewArray lastObject] view] setTag:1];
        [self.tabBarController setSelectedIndex:1];
    }
    @end
    

    “jumptToVC3” switches us to tab 2 and sets the frontmost view’s view tag property to 1. IF the frontmost view is VC2, this triggers an immediate segue to VC3. If the frontmost view is VC3, this sets up the back button correctly. If other View Controllers get added to this stack, this navigation will break.

    ViewController2
    Has a “move to VC3” button, wired to a storyboard segue to VC3 “toVC3”

        //  ViewController2.m
    
    #import "ViewController2.h"
    #import "ViewController3.h"
    
    @implementation ViewController2
    
        //we use the view.tag property as a switch:
        //0 = do nothing
        //1 = segue to VC3
        //2 = go to tab 0  
    
    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
        if (self.view.tag ==1){
            [self performSegueWithIdentifier:@"toVC3" sender:self];
        } else if (self.view.tag == 2){
            [self.tabBarController setSelectedIndex:0];
        }
        self.view.tag = 0;
    }
    
    - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if (self.view.tag ==1) {
            [[segue.destinationViewController view] setTag:1];
        } else {
            [[segue.destinationViewController view] setTag:0];
        }
        self.view.tag = 0;
    }
    
    - (void) viewWillDisappear:(BOOL)animated
    {
        self.view.tag = 0;
    }
    
    @end
    

    ViewController3
    Overrides the back button if it’s view.tag is set to 1. If you want both context’s back buttons to be consistent, you will need to override for the default behaviour as well. You will not be able to get a standard back button look for this override behaviour.

        //  ViewController3.m
    
    #import "ViewController3.h"
    
    @implementation ViewController3
    
    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
        if (self.view.tag == 1) {
            self.navigationItem.leftBarButtonItem =
            [[UIBarButtonItem alloc] initWithTitle:@"0.0"
                                             style:UIBarButtonItemStyleBordered
                                            target:self
                                            action:@selector(goBack:)];
        }
        self.view.tag = 0;
    }
    
    - (IBAction)goBack:(id)sender {
        [[[[self.navigationController viewControllers]
           objectAtIndex:0] view] setTag:2];
            [self.navigationController popToRootViewControllerAnimated:YES];
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
i got an object with contents of html markup in it, for example: string
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have been unable to fix a problem with Java Unicode and encoding. The

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.