Reputation: 3372
Okay, I am using a custom tab bar (not a tab based app) but I want the behavior of the MORE button showing up and behaving the same as it would if it was a tab based app if I more than 5 items.
Since this is simply a TABBAR, with TAB BAR ITEMS being added to it in the XIB of a normal view, it does just keep adding them to the TABBAR when it is displayed. How do I emulate/reproduce, inherit preferably the behavior of the Tab Based App, so that my tab bar would limit its display and show the more and behave appropriately?
And please don't tell me, go rewrite your app as a tab based application because that's not what I want to do, and cannot do for other issues.
Thanks in advance.
Upvotes: 0
Views: 2030
Reputation: 3586
The More button added to the TabBar is a functionality of the UITabBarController and not the tab bar itself. The UITabBarController has a tab bar, and adds behaviour such as the More button, the Edit and all the fancy stuff that you see in most TabBased Apps.
Normally this is used as the rootViewController of your application, but you should be able to add one to your non-tab-based application. However, you will need to rewrite some of your code.
For example, instead of having an array of Tab Items, a UITabBarController needs an array of all ViewControllers that need to be displayed. Each controller will become a tab item, the title and image displayed in each tab item are taken from the UIViewController associated with it. It will manage presenting and hiding the ViewController associated with the selected tab item.
If you do not wish to use the UITabBarController and still prefer the UITabBar, I guess that you have no choice other than implementing the behaviour yourself, perhaps by subclassing UITabBar. You will also need a localized version of the "More" text.
Upvotes: 1