2010-01-30 52 views
1

在线程“Is there a way to set a separate short title for UITabBar?”中询问(编辑)了这个问题:“如何在标签栏上显示视图短名称,以及在表视图中链接到相同视图时如何显示更长(更具描述性)的名称它有更多的空间)“。答案是为导航控制器和tabBar控制器分配不同的标题。我不认为这完全回答了这个问题。有两个地方tabBar标题被看到:在标签栏本身和“More ...”屏幕上,这是一个tableView。当视图在栏上时,为UITabBar设置单独的标题与更多...?

当在标签栏上显示标题时,标题需要缩短,但在“更多”视图中标题需要更长时间。有什么窍门可以实现这一点?

回答

0

回答我的问题:

// UITabBarControllerDelegate 
- (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed 
{ 
    if (changed) { // swap tabBar titles for the controllers with long and short names 
     int index = 0; // 0, 1, 2, 3 are on the tab bar, others are on the More tableView 
     for (UINavigationController *aNavController in viewControllers) { 
      if (index > 3) { // use long names, look for short names 
       if ([aNavController.tabBarItem.title ieq:@"Short"]) { 
        aNavController.tabBarItem.title = @"The Long Title"; 
       } 
      } else { // use short names, look for long names 
       if ([aNavController.tabBarItem.title ieq:@"The Long Title"]) { 
        aNavController.tabBarItem.title = @"Short"; 
       } 
      } 
      index++; 
     } 
    } 
} 
:在的UITabBarController delgate用蛮力
相关问题