0

I have a UITabBar where the user is able to select one of five items, when one of the items has been selected I then load a subview. The only thing is, is that the tabBar item is staying selected when I would like it to select (turn blue as the user touches it) then deselect straight away.

Effectively I have set up the different selections like so.

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
     switch (item.tag) {
        case 0: //New Code
        {

         }
//case 1, 2, 3, 4 etc...
}

If I then add something like this into one of the case's and the user selects a TabBar item, everything works fine but there is never a blue selection.

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
    {
      //case 1, 2
        }
            case 3: //New Code
            {
               [tabBar setSelectedItem:button3];
[tabBar setSelectedItem:nil];
             }
    //case  4 etc...
    }

So what I was hoping to get some help with is how to get the tabbar button to select then deselect straight away, much like you how see this happen on a UIButton.

any help would be greatly appreciated.

HurkNburkS
  • 5,492
  • 19
  • 100
  • 183
  • check out this http://stackoverflow.com/a/17313098/1328096 . – jamil Jul 19 '13 at 08:14
  • unfortunatly this dosnt work the way I need it too. I am wanting an automatic on off type look so when its selected it highlights then once your finger comes off the tabarbutton it goes back to its original state. – HurkNburkS Jul 21 '13 at 21:58

1 Answers1

1

Well I would suggest in 2 methods to solve this issue :-

  1. You could well add 2 images to your UITabBar using

    [Tabbar setFinishedSelectedImage:[UIImage imageNamed:@"selected_button"] withFinishedUnselectedImage:[UIImage imageNamed:@"unselected_button"]];
    Here you can show images in your tabbar and so place the deselected image again on the click.

  2. Remove the tabbar and add simply UIButtons that would serve the purpose of the Tabbar.

IronManGill
  • 7,222
  • 2
  • 31
  • 52