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
2010-08-10 23:16:26
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
2010-08-10 23:17:51
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
2010-08-10 23:40:32
Agree completely.
Adam Eberbach
2010-08-10 23:44:36