2010-08-10 50 views

回答

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" 
    } 
} 
+3

我不会推荐看标题,特别是如果你使用字符串本地化的东西。相反,将标签用于此目的,并定义一系列代表选项卡的整型值,定义一些常量以使您的代码在将来回到代码时更具可读性,并在代码上进行比较。 – jer 2010-08-10 23:40:32

+0

完全同意。 – 2010-08-10 23:44:36

0

uitabbaritem继承自定义标签和标题属性的uibaritem。

2

我宁愿让tabBar项目阵列上使用indexOfObject项目的指标:

NSUInteger index = [tabBar.items indexOfObject:item]; 
相关问题