How to programmatically create the ...More tabBar item?


#1

Hi I’m creating a tab more with 5 items. How can I programmatically create the Icon/item for “More”? If I use Interface Builder it can auto-magically create the Tab bar item identifier “More” with the 3 dots. I’d like to do this in code. Any ideas?

Does it have anything to do with UITabBarSystemItemMore? How can I make this work? Following the code in Chapter 7 I’d like to replace the “Time.png” for example with “More”

-Marcus


#2

The More… tab bar item will automatically be used if you have more than 4 (or maybe 5?) view controllers in a tab bar controller.

You can set a tab bar item’s icon to be that of the More… icon by choosing one of the various constants for the tab bar item, I believe. However, Apple has strict rules about using their pre-fabbed icons and they all have a specific purpose. Therefore, if you were to use the More… tab bar item for something that did not display a Navigation Controller with a table view root view controller that had additional options, they might reject your application.


#3

Thanks Joe
Its 5 then “More” will appear!


#4

Follow up:

Joe another question on the More … button. How would I go about getting rid of the “edit” button that appears when I click on More? The edit button seems to appear on/as a UINavigationItem I think. ( I haven’t skipped ahead to that chapter yet )

I hope this question makes sense.


#5

Technically, you can, but it is ugly and I’d imagine it is ugly because they don’t want you to do it.

	UIViewController *vc = [[[tabBarController moreNavigationController] viewControllers] objectAtIndex:0];
	[[vc navigationItem] setRightBarButtonItem:nil];

Of course, you can’t do this when instantiate the tab bar controller - you have to wait until the More navigation controller appears on the screen and only when it is on the screen. The only hacky way I can think of doing that is call that code in every view controller in the tab bar controller viewDidDisappear: method. Which is why it is ugly. (You can get ahold of the tabBarController in a view controller with [self tabBarController]).

There may be a better way of doing that, but off the top of my head, that is direction you are headed.


#6

Thanks again Joe. I’m looking forward to the other chapters. Excellent book btw.