tags:

views:

827

answers:

2

I am writing an App based on UITabBarController which has more than 10 viewControllers with corresponding UINavigationControllers. Each viewContoller has a (short) Title and a (long) navigationTitle. The short title shows up under the TabBar icon and the long title shows up on top of the navigation bar.

The UITabBarController displays the first 4 tabs and automatically adds a "More" tab which brings up a list of rest of the tabs. This list shows the (short) Title of each of the view controllers. How can I tell it to show the (long) navigationTitle instead?

A: 

You should try having all the tabs default to the (long) title, and then programmatically change the visible tabs to their (short) names. Let me know if you don't know how to programmatically change them. That might actually be a way to do what you wanted in the first place. I'll elaborate on prompt.

TahoeWolverine
Please tell me how to programmatically change the visible tabs to their (short) names. Meanwhile, I have achieved this by subclassing UITabBarController which also lets me change the colors of the MoreViewController.
I would also like to know your thoughts on this, I have a similar issue. I don't really want to subclass UITabBarController so programmatically changing would help. The problem is, the "configure" screen also displays the long names if you do this and I can't find a point to change the names before these icons come up.
bjtitus
I think it is much easier to do this by implementing a new data source for the more navigation controller and renaming the title of each cell. This means that the view controllers aren't being renamed each time but only the displayed names are. Otherwise, you have to change the title at least two times (before the config. screen and after) not including changing for when the bar items are loaded.
bjtitus
+1  A: 

I recently did this for an application and found the best way to do it was to create a custom data source that renamed the title in the more table to the long name. It is simply impractical to do it the other way because the names must be changed far too many times (once on tab bar load, once on more view load, and again on customized section load, and again on customized section close).

I found the basic instructions here and simply made it change the title. I use a plist to hold all of the short and long names for each section.

My code for the cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [originalDataSource tableView:tableView cellForRowAtIndexPath:indexPath];
    cell.textLabel.text = [[sections objectAtIndex:indexPath.row+4] objectForKey:@"LongName"];
    return cell;
}
bjtitus