views:

47

answers:

2

How can I determine if a UITabBarItem has the title "Hello" and is in position 0?

A: 

uitabbaritem inherits from uibaritem which defines the tag and title properties.

ennuikiller
A: 

Use the items property of the UITabBar, like:

if([[myTabBar items] indexOfObject:myTabBarItem] == 0)
{
  UITabBarItem* theItem = [[myTabBar items] objectAtIndex:0];

  if([theItem.title isEqualToString:@"Hello"])
  {
    // it's in position 0 and has title "Hello"
  }
}
Adam Eberbach
I wouldn't recommend looking at the title, especially if you're using things like string localization. Instead, use the tag for this purpose, and define a range of integer values which represent your tabs, define some constants to make your code more readable for when you come back to it in the future, and compare on the tag.
jer
Agree completely.
Adam Eberbach