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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:36:41+00:00 2026-06-14T05:36:41+00:00

I have set up a delegate for my UITabBarController and have the following delegate

  • 0

I have set up a delegate for my UITabBarController and have the following delegate method:

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {    
        [self.navigationController popToRootViewControllerAnimated: YES];
        return NO;
}

The method fires and in the context, I’m one or two levels into table views. The root view controller gets displayed correctly, but the navigation bar doesn’t get reset, and still has a “back” button from one or two levels into the table views.

(The above delegate method is a simplified form of what I’m trying to do in my app, but still exhibits the problem. In my app, I need the root view displayed when I return to the original tab, so am trying to pop to the root view before I leave).

popToRootViewControllerAnimated not working correctly suggests a time lag issue, but that doesn’t appear to be what’s going on in my case. I can wait as long as I want before doing the shouldSelectViewController and the nav bar “back” button still is messed up.

The delegate is:

@interface BasicPlaceItemComment : UIViewController<UIAlertViewDelegate, UITabBarControllerDelegate> {
    // data members ommitted
} 

This is the class from which I derive all of my table views.

  • 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-14T05:36:42+00:00Added an answer on June 14, 2026 at 5:36 am

    The issue seems to be that I was subclassing UINavigationController to solve a different problem. When I remove this subclass, the issue goes away. That is, the “back” buttons are not messsed up anymore when I do popToRootViewController without subclassing UINavigationController. This, however, raises another problem. I was subclassing UINavigationController in order to solve the problem stated in UINavigationController and UINavigationBarDelegate.ShouldPopItem() with MonoTouch

    With both my nav bar and my tab bar I want to be able to put up a message “Are you sure you want to Quit?” alert when the back button (or another tab) is pressed in the case when some data in the displayed view has changed (before navigating away from that view, and possibly canceling navigating away from that view).

    So, while this a partial answer, my problem still stands. I still need a means to gain control when the user types the back button or another tab. So, it seems I need:
    1) A means to have a different delegate than the UINavigationController for UINavigationBarDelegate method shouldPopItem, or
    2) Some means to subclass UINavigationController but not get the back button messed up as is currently happening when I click on a tab and call popToRootViewController.

    Further thoughts?

    More on 11/3/12

    It’s not UINavigationController subclassing per se that was causing the issue. I was inadvertently returning NO from my delegate method

    // This method returns true when the navigation bar should pop an item
    - (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item {
    

    when I did a popToRootViewController. I now have a method in my UINavigationController subclass:

    - (void) popToRoot {
        regularPop = YES;
        [self popToRootViewControllerAnimated: YES];
    }
    

    that causes shouldPopItem to return YES, which I use instead of popToRootViewController. Most of my problems are solved!

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

Sidebar

Related Questions

I have a UITabBarController and I have set up its delegate method didSelectViewController ,
I have set the delegate of my textfield to self and I have added
I have a UITabbarController set by the Interfacebuilder. The tabbarcontroller has 5 tabs, the
I have 2 UIViewControllers(A,B). A is set as the delegate for B and then
Right now, I have to do this private delegate void set(int obj); //declare the
I have set my UISlider up to respond to value changed events: [customSlider addTarget:self
I have the following object structure: UITabBarController UINavigationController UITableViewController It used to work, but
I am creating and adding UITabBarController programatically in my App Delegate. I have 5
So, I have this view hierarchy in my app: UIWindow UIViewController UITabBarController -> 4
I'm trying to create a UISearchDisplayController programmatically. I have a method which should set

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.