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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:36:57+00:00 2026-05-30T23:36:57+00:00

I have a tab bar MainViewController with a few tab bar buttons, the first

  • 0

I have a tab bar MainViewController with a few tab bar buttons, the first being View 1 which is a navigation controller with a stack of up to 3 or 4 children. The final tab bar button is SettingsViewController, with a function similar to ‘Logout’ within it, which calls a method on the AppDelegate which removes MainViewController and sends the user back to a login page.

When pressing the logout button on SettingsViewController I want the AppDelegate to set the selected tab to be View 1 (which I’ve done), send the user back to the logon view (also done) but also popToRootViewController on View 1 which is the bit I’m struggling with.

I’ve tried using the viewControllers property on the tabBar to grab a reference to the view controller at index 0 but that doesn’t appear to be the correct way unless I’m implementing it incorrectly.

My most recent attempt:

// Fine
mainViewcontroller.tabBarController.selectedIndex = 0;

// Not so fine
NSArray *allViewControllers = [mainViewcontroller.tabBarController viewControllers];
View1 *vc = [allViewControllers objectAtIndex:0];
[vc.navigationController popToRootViewControllerAnimated:NO];

Another attempt at just iterating through all view controllers in the tab and popping to the root which equally doesn’t seem to work:

for (UIViewController *viewController in mainViewcontroller.tabBarController.viewControllers)
{
    [viewController.navigationController popToRootViewControllerAnimated:NO];
}

Can anyone help?

  • 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-05-30T23:36:58+00:00Added an answer on May 30, 2026 at 11:36 pm

    Just for closures sake… using exactly the same code I pasted in my question worked find when I recreated the tab bar controller programatically instead of in IB.

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

Sidebar

Related Questions

Description I have a Tab Bar Controller with a navigation controller tab. The first
I have a tab bar application with a navigation controller and view controllers inside
I have a tab-bar and navigation controller application (like Youtube app or Contacts app).
I have root view with both tab bar and navigation bar visible at the
I have a Tab Bar with a navigation table view. My app crashes when
I have a tab controller, which contains a navigation controller which again contains a
I have a tab bar application and when I display a modal view controller,
I have a tab bar controller with five buttons. That controller has a tab
I have a Tab Bar controller inside a Navigation controller. I want to create
I have a tab bar controller and each tab consist of a navigation controller.

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.