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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:11:24+00:00 2026-06-05T13:11:24+00:00

I have a tabBar initilized in xib file, question is, I want to deselect

  • 0

I have a tabBar initilized in xib file,

question is, I want to deselect the item that I tapped before,

but I can’t,

I tried

self.tabBar.selectedItem = 0;
self.tabBar.selectedItem = nil;

in any place I can, but it just does not work,

how can I deselect a tabBar item after I tapped it?

Thanks a lot!

  • 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-05T13:11:27+00:00Added an answer on June 5, 2026 at 1:11 pm

    Heres my solution to your problem below

    .h

    @interface DetailViewController : UIViewController <UITabBarDelegate>{
    
     //..
        IBOutlet UITabBar *myTabBar; //notice IBOutlet, hook this up to your tabBar in InterfaceBuilder
    
        }
    
        @property (strong, nonatomic) IBOutlet UITabBar *myTabBar;
    

    .m

    @synthesize myTabBar;
    
    //..
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        [self configureView];
    
        actionTabBar.delegate = self; // This sets up tabbardelegate method
    }
    
    //..
    
    #pragma myTableDelegates
    // a Case for each button
    - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
    {
        switch (item.tag) {
            case 0:
            {  
                if (check for condition here) {
                     // do some tab stuff here, maybe load a view or something
                }
                else if (check for condition here) {
                    // do some stuff here like unloading views etc
                  [myTabBar setSelectedItem:nil]; //clears the previously selected cell
        // this means only one cell can be selected at a time.
                }
    
            }
                break;
            case 1:
            {
                NSLog(@"item 1 selected");
            }
                break;
            case 2:
            {
                NSLog(@"item 2 selected");
            }
                break;
            default:
                break;
        }
    
    }
    

    This should get you started, its pretty much the same code I use in a project of mine so it should work, you will just have to use your own if statments to get that tabbutton selection and deselection…. if this is not what your looking for the

    [myTabBar setSelectedItem:nil];
    

    will be enough for you to clear any selected cells in the tabBar.. however you must remember myTabBar is an IBOutlet so you have to hook it up in Interface Builder to the tabbar you have in there, alternately you could do this in code also but it sounds like your working with a .xib file so the above solution should be sweet.

    I have not built and run this specific code so there might be an error in it, let me know if you need any more help.

    Anyway I hope this works out for you 🙂

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

Sidebar

Related Questions

I have a tabbar app and I want to add login window that will
I have an tabbar but i want to switch to another view on a
I have a tabbar application. And the item of first tab is Navigation Controller.
I have two tabbar items(views) that use the same data, whats the best solution
I have a tabBar, and I want to customise the items in the tab
I have an TabBar app that I would like to be in landscape and
I have a tabBar with 4 tabs on it, and I want to perform
I have a TabBar App. I have created a UITableView class called Schedule that
I have a tabbar application that has one screen that displays statistics based on
I have a tabbar Controller . which have 5 Tabs in that one is

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.