如何判断UITabBarItem的标题是“Hello”并且位于0位置?
答案 0 :(得分:2)
我宁愿使用indexOfObject
项数组中的tabBar
来获取项目的索引:
NSUInteger index = [tabBar.items indexOfObject:item];
答案 1 :(得分:1)
使用UITabBar的items
属性,例如:
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"
}
}
答案 2 :(得分:0)
uitabbaritem继承自uibaritem,它定义了标签和标题属性。