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
1
vote
2 answers

Which Controller was before?

I got TabBar Application with 3 ViewControllers. Can i know from the ViewControllers's method which ViewContoller was desplayed before (1 or 2)? Or maybe i open VeiwController from some other .xib
Eugene Trapeznikov
  • 3,220
  • 6
  • 47
  • 74
1
vote
2 answers

Xcode Storyboard with a UITabViewController - change tabs from button

I've got a project setup using a Storyboard that contains a UITabViewController as the initial root view. One of the tabs loads a NavigationController that in turn loads a custom view controller class. From the custom view controller, I have a…
PrairieHippo
  • 347
  • 2
  • 12
1
vote
2 answers

Detect which Tab was selected on TabBarController from inside a TableViewController - Code Reuse

I have an application which has 5 tabs on a TabBarController. For simplicity sake lets say they are Tab A, B, C, D, and E. Each tab takes the user to a TableViewController which is embedded in a Navigation controller. Each tab also has its own…
ElasticThoughts
  • 3,417
  • 8
  • 43
  • 58
1
vote
2 answers

tabbar item image and selectedImage

I have a tab bar controller (its a tab bar based application, so tab bar is on MainWindow.xib). In this xib, I have added 4 tab bar items and I have set the image of all tab bar item. Due to this, I am facing 2 issues: 1) The image is white-colored,…
anshul
  • 846
  • 1
  • 14
  • 32
1
vote
1 answer

iPhone Dev - View Switcher using round rect buttons

I'm a fairly new programmer and I had been taught how to switch between two views using a toolbar button as the root controller. I am now making an app for fun that switches between 5 views (but for the look of it I dont want to use a tab bar).…
nfoggia
  • 513
  • 1
  • 8
  • 28
1
vote
1 answer

I would like to update a tableView from a different viewController is it possible?

Thanks for a great resource! I am currently working on a project that involves Tab Bars. Basically I have one .xib file that contains 5 Navigation Controllers, within those each has a view controller then a tableView. My question is, how do I get a…
1
vote
1 answer

can text be written in badges

I am writing an application in which i inform the user of some events by 2-3 letter words written in tab badges. It works fine and according to me looks fine. The thing is; in the iOS Human Interface Guidelines, under the Appearance and Behavior…
aytunch
  • 1,326
  • 1
  • 16
  • 31
1
vote
1 answer

UITabBar inside Master View

I need to create an app with a Split View but I need to add a tab bar in the Master side of the split, I've read some stuff in this forum but I just can't get it right. I understand that when you have a split view you actually handle two view…
1
vote
6 answers

tab bar item title programatically not showing in objective c

I try create tab bar controller programatically, it works but I can not set title to ta bar items. I can not see title when I running my application. My code is here. Please help me, what is the problem? - (void)viewDidLoad { [super viewDidLoad]; //…
1
vote
2 answers

How can I load a NIB that isn't a view in a UITabViewController?

I want to load a nib that isn't a view in a UITabViewController. Here's what I have now and it isn't working, but it should give you an idea of what I want: - (IBAction)PlaylistButtonPressed:(id)sender { MusicPick *music = [[MusicPick alloc]…
Bryan Cimo
  • 1,268
  • 1
  • 19
  • 34
1
vote
2 answers

UITabBarController with UINavigationController, hide UINavigationController toolbar on hidesBottomBarWhenPushed, not UITabBarController tab bar

I have a UITabBarController root view controller with three view controllers, once of which is a UINavigationController with a UIViewController containing a UISearchDisplayController and a UITableView. The UINavigationController toolbar is not…
1
vote
1 answer

Moving a navigation stack to the more-tab

I have a UINavigationController on some tab of a UITabBar. When I drill down into the navigation controllers tableViews, move it into the more-tab, and then select the entry in the tableview in the more-list, i get the viewController that was…
Ahti
  • 1,420
  • 1
  • 11
  • 20
1
vote
1 answer

Calling a tabbar view controller from a view controller which is already imported by called viewcontroller?

Maybe a stupid question but I have to do it as soon as possible. My problem is: I have four tabbar controllers A,B,C,D and these are imported a viewcontroller (suppose name button controller) at the navigation bar. So, A,B,C,D are importing this…
1
vote
2 answers

Custom background on UITabBarItem not set on second tap

I have a custom tabbar with custom tabbar items. Everything works as I want it to, besides when a tap has been tapped and is in a selected state, it does not use my custom highlighted background if re-tapped. So far I set: UIButton *tap =…
andershqst
  • 1,454
  • 1
  • 14
  • 24
1
vote
1 answer

How can i control the tabbar item via button click?

My facing some serious problem.So I am explaining very specifically. Two view Controller A) UITabbar Controller B) View controller containing scrollview of buttons. I have subview B controller [blue button in the image] on the navigation bar of A…
Emon
  • 958
  • 3
  • 10
  • 28
1 2 3
99
100