Questions tagged [uitabbarcontroller]

The UITabBarController class implements a specialized view controller that manages a radio-style selection interface. This tab bar interface displays tabs at the bottom of the window for selecting between the different modes and for displaying the views for that mode. This class is generally used as-is but may be subclassed in iOS 6 and later.

The UITabBarController class implements a specialized view controller that manages a radio-style selection interface. This tab bar interface displays tabs at the bottom of the window for selecting between the different modes and for displaying the views for that mode. This class is generally used as-is but may be subclassed in iOS 6 and later.

Each tab of a tab bar controller interface is associated with a custom view controller. When the user selects a specific tab, the tab bar controller displays the root view of the corresponding view controller, replacing any previous views. (User taps always display the root view of the tab, regardless of which tab was previously selected. This is true even if the tab was already selected.) Because selecting a tab replaces the contents of the interface, the type of interface managed in each tab need not be similar in any way. In fact, tab bar interfaces are commonly used either to present different types of information or to present the same information using a completely different style of interface. Figure 1 shows the tab bar interface presented by the Clock application, each tab of which presents a type of time based information.

enter image description here

You should never access the tab bar view of a tab bar controller directly. To configure the tabs of a tab bar controller, you assign the view controllers that provide the root view for each tab to the viewControllers property. The order in which you specify the view controllers determines the order in which they appear in the tab bar. When setting this property, you should also assign a value to the selectedViewController property to indicate which view controller is selected initially. (You can also select view controllers by array index using the selectedIndex property.) When you embed the tab bar controller’s view (obtained using the inherited view property) in your application window, the tab bar controller automatically selects that view controller and displays its contents, resizing them as needed to fit the tab bar interface.

Tab bar items are configured through their corresponding view controller. To associate a tab bar item with a view controller, create a new instance of the UITabBarItem class, configure it appropriately for the view controller, and assign it to the view controller’s tabBarItem property. If you do not provide a custom tab bar item for your view controller, the view controller creates a default item containing no image and the text from the view controller’s title property.

As the user interacts with a tab bar interface, the tab bar controller object sends notifications about the interactions to its delegate. The delegate can be any object you specify but must conform to the UITabBarControllerDelegate protocol. You can use the delegate to prevent specific tab bar items from being selected and to perform additional tasks when tabs are selected. You can also use the delegate to monitor changes to the tab bar that are made by the More navigation controller, which is described in more detail in The More Navigation Controller.

For more information about using tab bar controllers to build your user interface, see View Controller Programming Guide for iOS.

The Views of a Tab Bar Controller

Because the UITabBarController class inherits from the UIViewController class, tab bar controllers have their own view that is accessible through the view property. The view for a tab bar controller is just a container for a tab bar view and the view containing your custom content. The tab bar view provides the selection controls for the user and consists of one or more tab bar items. Figure 2 shows how these views are assembled to present the overall tab bar interface. Although the items in the tab bar and toolbar views can change, the views that manage them do not. Only the custom content view changes to reflect the view controller for the currently selected tab.

enter image description here

The More Navigation Controller

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.

The interface for the standard More item includes an Edit button that allows the user to reconfigure the tab bar. By default, the user is allowed to rearrange all items on the tab bar. If you do not want the user to modify some items, though, you can remove the appropriate view controllers from the array in the customizableViewControllers property.

State Preservation

In iOS 6 and later, if you assign a value to this view controller’s restorationIdentifier property, it preserves a reference to the view controller in the selected tab. At restore time, it uses the reference to select the tab with the same view controller.

When preserving a tab bar controller, assign unique restoration identifiers to the child view controllers you want to preserve. Omitting a restoration identifier from a child view controller causes that tab to return to its default configuration. Although the tab bar controller saves its tabs in the same order that they are listed in the viewControllers property, the save order is actually irrelevant. Your code is responsible for providing the new tab bar controller during the next launch cycle, so your code can adjust the order of the tabs as needed. The state preservation system restores the contents of each tab based on the assigned restoration identifier, not based on the position of the tab.

For more information about how state preservation and restoration works, see App Programming Guide for iOS.

6522 questions
2
votes
2 answers

Resetting Tab bar controller's view controllers

In my Application I have creted view controllers for Tab Bar using XIB. I mean I added view controllers in tab bar using XIB. See picture, So my application is like this. I have a log out functionality that will show login page. From Login page I…
rakeshNS
  • 4,227
  • 4
  • 28
  • 42
2
votes
1 answer

Make a fine tabBar icon

As we know the default icon size for the tabBar is 30x30 point. I have an icon with thin lines and the display property is not that good. Its edge is not sharp. But I find the tabBar icon of music.app is really pretty with sharp edge. Is there any…
lu yuan
  • 7,207
  • 9
  • 44
  • 78
2
votes
4 answers

Tab bar item third touch for a table view not scrolling to the top

I have a tab bar item which is connected navigation controller with a UIViewController as the root view controller. The first touch on the tab bar item switches to that view. The second touch pops to the root view controller. The third touch does…
Jeffery Thomas
  • 42,202
  • 8
  • 92
  • 117
2
votes
2 answers

Add UITabBarController or similar User Interface View on the UIViewController other than rootViewController

I am trying to create an app that navigates from the rootViewController using UINavigationBar to the nextViewController which is UITabBarController or similar UIView with UITabBar with couple of UITabBarItems. So please suggest. Suggestions for both…
Neo
  • 2,807
  • 1
  • 16
  • 18
2
votes
2 answers

Loading a view controller from viewDidLoad

Hello I want to create a tabbar application in iPhone using X-code.I have one splash screen and then after that I have my Home Screen where I want to create tabbar in that view. so, I create a tabbar in my ViewDidLoad method. - (void)viewDidLoad { …
jaynaiPhone
2
votes
1 answer

Is there any way to set 4th tab More tab in UITabBarController in iPhone

I have 6 tabs in my iOS app. and i need to set 4th tab as more and show 3 tabs as table in 4th tab. Is there any simple way to do this. to tell iphone-sdk to treat 4th tab as last tab and as "more" ?
Mihir Mehta
  • 13,743
  • 3
  • 64
  • 88
2
votes
1 answer

How to make a view have a semi-transparent border and show the view below

Probably a bit of a newbie question, but .... I am writing an iPhone app which uses UITabBarController. In Interface Builder I've setup the tab bar in MainWindow.xib. I have 4 tabs, and each one is set to load the xib for the appropriate…
Nathan Russell
  • 3,428
  • 5
  • 30
  • 51
2
votes
2 answers

iPhone: ABPeoplePickerNavigationController won't show up properly in UITabBarController

I am trying to show up contacts from iPhone contacts book in UITabBarController. I came so far: - (void)contacts { ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init]; // place the delegate of the picker…
NCFUSN
  • 1,624
  • 4
  • 28
  • 44
2
votes
5 answers

How To Change Tab bar color in Xcode

How do I go about changing the tab bar color in this code? My tab bar is black. On click changes it to blue. I want to change the tow color to any other color. This code is from :application.m and there :rotatingTabBarController.m…
Moh ali
  • 31
  • 1
  • 1
  • 6
2
votes
0 answers

Which UINavigationController are UIViewControllers pushed onto that are accessed through the "More" tab in UITabBarController based Apps

I have an UITabBarController based app which shows a number of UINavigationController based tabs where I'm loading individual UIViewControllers onto. To support interface rotation, I'm trying to forward the willRotateToInterfaceOrientation and…
zero0cool
  • 352
  • 4
  • 11
2
votes
2 answers

How to use different TabBar's when i click a tabbar item?

I have a UITabBarController in my mainWindow.xib,when i click on a tabbar item in UITabBarController i want a new view to appear with different UITabBarController....So pls help me to do this by suggesting me tutorials and examples ... Thank you.
user1285402
  • 143
  • 2
  • 12
2
votes
2 answers

Tab Bar Item Images Invisible in MoreNavigationController with Black Background

I have a Tab Bar (UITabBarController) application with a "More" View Controller because of having more than 5 views. The rest of my application has a black background and white text, and I have been able to customize this table to match this. As a…
Julian
2
votes
1 answer

"Slide" segue between UITabBar views

My iOS 5 app uses storyboarding with a UITabBarController. There are three "tabs" each displaying a view controller which has been linked using a relationship back to the UITabBarController. At the moment each view controller appears when you tap…
Skoota
  • 5,280
  • 9
  • 52
  • 75
2
votes
1 answer

How to reload or refresh data in tab bars in tab bar controllers with new data?

I have 3 tabs with tab bar controllers. All the 3 view controllers in the tab bar have navigation controllers to go to other view controllers on their own. One of the view controllers in the tab bar is with the map and map annotations(map view…
2
votes
1 answer

How to edit table rows in tabbar based application

All I am developing one demo application using Tab bar controller containing 3 tabs in it. In first tab I am using one Table view controller . I am having a problem in editing (adding/deleting) the table rows. I am not able to add or remove the rows…
iCoder
  • 1,298
  • 1
  • 9
  • 25