views:

169

answers:

1

In the thread "Is there a way to set a separate short title for UITabBar?" this question is asked (edited): "How do I give views short names for display on the tab bar, and longer (more descriptive) names when the same view is linked to in a table view (which has more space)." The answers were to give separate titles to the navigation controller and the tabBar controllers. I don't think that completely answers the question. There are two places the tabBar title is seen: on the tab bar itself and on the "More..." screen which is a tableView.

When visible on the tab bar the title needs to be short, but when on the More view the title needs to be longer. What's the trick to accomplish that?

A: 

Answering my own question: use brute force in the UITabBarController delgate:

// 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++;
        }
    }
}
Jeff