I have a simple app where the only view controller has an outlet to a UITabBar. It also implements UITabBarDelegate and is set as the delegate for the UITabBar:
@interface TheMainViewController : UIViewController <UITabBarDelegate>
{
IBOutlet UITabBar *theTabBar;
}
I implemented the following method Which gets called whenever any of my 4 UITabBarItems get tapped. I tried just doing something really simple:
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
tabBar.selectedItem = [tabBar.items objectAtIndex:0];
return;
}
In theory, it should always stay selected on my first tab and it works perfectly when I just tap any UITabBarItem (nothing happens, the first one always stays selected). But when I touch a UITabBarItem and hold it (not taking my finger off) the selection changes anyway ! Debugging, everything gets called properly.
It's like changing the selectedItem property doesn't have any effect is the user still has the item "down" (with his finger on it).
What would be a good workaround? I tried overloading UITabBar and messing with touchesBegan and touchesEnd but they don't even get called. Same with UITabBarItem.
Oh and please don't suggest using a UITabBarController as it is not flexible enough for my application.
So frustrating....thanks!