iOS UITabBar - can I modify how many tabs are shown at once? - iphone

I'm interested if it is possible to modify the default behavior of UITabBar to display only 4 tabs total, with the 4th tab being ... More.
By default, tabbar displays up to 5 tabs with the last one being "... more", if tabbar holds more than 5 controllers. My designer expressed the idea that it may be easier for the user to navigate the app if we leave only 3 major controllers in the tab bar, with all "optional" content hidden in the more list.
Is there a default option or some tweak that I can apply to a UITabBar to change how many tabs it displays at once?

Similar to what Michael Henry suggested you can create the 4th tab as ...More but instead of using a UITableViewController why not re-draw the options at the bottom of the UITabBarController and show the next set of tabs with the first obviously being Previous...
With this methodology you'd likely have to keep track of what state your TabBar is in so that it properly influences which UIViewController is shown upon tapping a tab button on the second page of tabs.
I'm hitting this answer on an iPad or else I'd dump a code example. Sorry.

Related

What is the maximum number of view controllers that can be part of a UITabBarController?

Please answer this question.
I know that it is pretty trivial, but I do not possess sufficient knowledge to be able to answer it myself, that is why I am asking the readers of this question.
The maximum amount of Tabs before a "more" button appears is 4, but you can essentially have as many as you want as long you have enough memory.
From the documentation
The tab bar has limited space for displaying your custom items. If you add six or more custom view controllers to a tab bar controller, the tab bar controller displays only the first four items plus the standard More item on the tab bar. Tapping the More item brings up a standard interface for selecting the remaining items.
You can change the maximum number of tabBar items before to show tap more it is possible using KVC
[self.tabBar setValue:#(numberOfMaxToShowTabMore) forKey:#"customMaxItems"];
And this code you must insert before add controllers in tabBar

Is there a way to implement four tabbed uitableviews that all have the same uinavigationbar

I am working on a mobile version for my company's web app. The structure of this application requires uitableviews with a tab bar on the bottom and a navigation bar up top to return to the previous view. As you drill down in the application the tab bar items change at each level allowing selection of different views pertaining to that specific level in the app. I need a way to implement this with a navigation bar on top that navigates back to the previous screen on every tab in said tab bar when a back button is clicked on any of the tabs.
for example: let's say i start out with an items tab and a simple about tab. When i click items it drills down to a new view called subitems and the tabs for this view are subitems, favorites, details, and notes. I want the navigation bar to go back to the previous screen when i click the back button on any one of these four tabs.
Is this at all possible? I can't seem to find anything related to this type of structuring within an app. any help/examples would be greatly appreciated.
I know that a negative answer always sounds bad, but I tried to do the same a few months ago and I could not find a way of doing it using the standard UITabBarController/UITabBar. Take also a look at this question/answer.
The good news is that it is not that difficult to implement from scratch a tab bar controller that can be pushed on a navigation stack. There are also several examples around, one is BCTabBarController. GtabBar is another example.
I actually found a way to do it you just have to implement the navigation bar's leftbarbuttonitem instead of the traditional back button. Then I just created a method that is invoked when the back button is pushed this updates the navigation stacks of all four views within the tab bar and sets the tab bar items accordingly to match with the previous views we are navigating back to. . . so long story short...it is possible.

Best iPhone app approach for project

I'm building an iPhone app and I'm sort of confused about which approach should I choose for views and controllers.
I would like to have a tabbar at the bottom with three options. I would also like to have a main view displayed when the app shows (along with the tabbar) but I don't want this view to be part of the tabbar options.
So, when the app begins, the tabbar has no option selected but the main view displayed. When a tabbar options is selected, in its top bar it should display a back button to the main view. When the back button is pressed, the main view display again with no tabbar option selected.
Which approach should I choose?
Hope it makes sense.
Thanks.
I understand what you're trying to do, but you shouldn't do that. I don't like that design at all. You should have one navigation controller for each tab.
You should probably read Apple's Human Interface Guidelines as it's possible they would reject your App if they thought such an implementation with a TabBarController was confusing.
As an alternative, you could possibly have the "main view" as you call it accessible with a button in the Navigation bar at the top and then add that to all three tabs. Not necessarily a better design but you probably wouldn't be breaking the guidelines.
A better alternative might be to use a UIToolBar at the bottom instead of the Tab bar which has the three buttons spawning your views modally which can then be dismissed as you suggest.
Remember though, your App's users have built up a knowledge of how App's are generally supposed to navigate, feel and control so you should think carefully before deciding to go against that.
Firstly, I think you should reconsider giving your Main View it's own tab. That way it's a no-brainer for the user to return to that screen. BUT, if you STILL don't like that idea, read on...
The UITabBarController has the unfortunate side effect of not being able to be removed once created (even if you delay it's creation by instantiating it programmatically).
SO...
Option 1: Make your MainView a modalPresentation sub-view, displaying it ON TOP of one of the views in your tab bar (hiding the tabs until you're ready to show them again).
Option 2: Give a subview of your first tab a...
mySubViewController.hidesBottomBarWhenPushed=YES;
This will make the UITabBarController disappear temporarily (just on that view, until you're ready to show the tabs again).
Both options seem kinda messy to me, but they are possible. Depends on how well you execute them, I suppose.
Hope this helps!
You could add the main view as another tab.
OR
You present the main view modally when the app starts over the tab bar views.
The first option would be used more if the view holds the same kind of content as the tabs, for example if the app was an online store, the tabs would be Categories, Search and Recently Added, with what you call the "main view" being the Home page (showing offers or something). (So all the views/tabs would be showing products on the store)
The second option would be more if the content of the main view is different to the tabs.
Keeping with the online store example, if the tabs were Categories, Search and Recently added and what you call the "main view" being a login/logout screen. (so the tabs would be showing products, but the modal view ("main view") being more admin related, and it's main purpose not being to display products.

How to hide tab of the tabBarController?

I want to create a Tab in the TabBarController but i don't want to show that on the tabBar...i mean it should be there but invisible...
like I have 5 tabs in my tabBarController and I want that my fifth Tab only is invisible...
is this possible??
There's no way to hide an individual tab. You could give it a blank icon, I suppose, but you'd still see the space where the tab is. If you had more than 5 tabs, you could arrange for this invisible tab to be on the More... tab item, so it wouldn't be immediately visible but the user could access it.
If you don't want the user to be able to access it, one has to wonder why you want to include it in the tab bar controller in the first place. Rememeber: when you find yourself fighting against the framework like this, there's usually a much better way to do what you're trying to do.
Not really—the tab-bar controller is pretty specifically implemented so that any view controller it manages can be accessed from the tab-bar UI somehow, be it on the bar itself or in the “More” section. What are you trying to accomplish?

How to add "more" button to Tab Bar?

My iPhone app has a tab bar controller at the bottom of the view - and at the moment I have three buttons on it. However, I want to add more, but to do so I need to turn the last of the three buttons into a "More..." button, because otherwise the text on the other buttons runs into each other.
I know that if you have over 5 buttons in the tab bar, then it automatically creates a more button - but is there a way to manually invoke this with the editing capabilities?
Thanks.
You do not have to manually create a "More..." button. Simply add all of the View Controllers that you need to the Tab Bar Controller and it will handle the rest.
You can set the last bar button as a "More" button even when there are only three tabs. The initialisation code for that tab bar item would be:
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMore tag:0];
Make your names shorter, or don't use a tab bar. You will have five or six view controllers, but only want two will be accessible at any given time? If two thirds of your views will be in the "more" list, why not just display all of them in a list? Then you could reclaim the space at the bottom, and no view would require have extra taps.
If you really want to do this, you should write a replacement for UITabBarController. I looked through UIKit, and even tried swizzling -_viewControllersInTabBar, but the five button limit is assumed in several places in UITabBarController, so you're better off writing your own.
You may have noticed that some iPad applications, like YouTube, have more than five tab bar items:
(source: apple.com)
How can this be, if UITabBarController is so obsessed with having no more than five view controllers? Maybe Apple added some kind of private method to UITabBarController in the 3.2 SDK that could help you. Maybe it's called something like -_setMaximumNumberOfItems: and maybe it sets an NSUInteger instance variable called _maxItems. If Apple did add such a private method, you would still need to wait for an iPhone-compatible version of 3.2 to be released, and even then, using private methods is Bad.
Change your tabs names. Not that big of a deal.
so it is not possible to even make 6 view tab bar application ?
even if the name of each is super short
let's say something like that
red red red red red
instead of yellow yellow yellow yellow yellow