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
1 answer

MainWindow IBOutlet properties for window, tabBarController log as (null) even though outlets are connected

In my AppDelegate.h I have @property (nonatomic, strong) IBOutlet UIWindow *window and @property (nonatomic, strong) IBOutlet UITabBarController *tabBarController. In the implementation I @synthesize *window = _window, *tabBarController =…
1
vote
1 answer

How to switch to another tab of UITabBar without touching a tab?

I have a tab bar setup and I want to be able to let the user change options and after the last one is selected or by pressing a button on the view, be able to automatically switch to another tab. Simply, I have 4 tabs setup and on one, I pick an…
Bryan Cimo
  • 1,268
  • 1
  • 19
  • 34
1
vote
3 answers

Set original images to tab bar items

I would like to know in UITabBar,if there's any way to set the colored(original) images to tab bar items,Upon several searches I came to find out the way to change the color of tab bar i.e. set a colored bar image which will do the…
Eshwar Chaitanya
  • 697
  • 10
  • 21
1
vote
0 answers

Video compression changes custom tab bar in iOS 5

I have implemented a custom tabbar in my app. Where I can scroll on the tab, and also the tab can have more than 5 buttons. The problem is when i pick a video with imagepickercontroller, the compressing video dialog box shows up. The video is…
1
vote
1 answer

iOS - Login view in UITabBarControler best practice

I've tabbar controller with 6 to 7 tabs on it with customization allowed (means that the user can change the order of tab bar display). And tab 1,3,5,7 requires the user to login access before seeing any contents on the view. I don’t know as to how…
mohan
  • 41
  • 1
  • 4
1
vote
1 answer

Select second tab from ModalViewController

In my app delegate I load a view controller on top of my tabbar. This controller had three buttons on it, one to navigate to each tab. When the second button is pressed, I want to dismiss the view controller and go to the second tab. But this…
1
vote
1 answer

How to load a different view controller when changing the tab bar in the master view controller?

I am creating an iPad as in the link. In this one I need to load different viewcontrollers when I change the tab in the masterside. How can I implement this? I have created the tabbar controller as follows: in the Appdelegate.m file -…
Mithuzz
  • 1,091
  • 14
  • 43
1
vote
1 answer

Alternative to subclassing UITabBarController

It seems that UITabBarController should not be subclassed. How would you recommend that I implement a TabBarController in a rotatable DetailView? Thank you!
AlexR
  • 5,514
  • 9
  • 75
  • 130
1
vote
3 answers

Tabbar controller after showing one view controller

I would like to ask if it's possible to show a tabbarcontroller after I showed one view controller. I've seen lots of tutorials about tabbarcontroller but they were all put in the AppDelegate using this line: - (BOOL)application:(UIApplication…
JCurativo
  • 713
  • 6
  • 17
1
vote
1 answer

MonoTouch: how to add UITabBarController

A bit confused with wiring controllers, I need some help I create a new Monotouch project (Master-Detail). Now, when I click on the tableview, I want to load a new view with a tabbar. SO I double-click on the DetailViewController.xib, and drag-drop…
1
vote
3 answers

Cocoa Touch UITabBar action on tab switch

I have a UITabBar with a number of UITabBarItems. I've assigned a different view controller to each of these. I want to load some data etc., when each button is clicked. Therefore I will like to know where to put that code? I tried implementing…
phidah
  • 5,794
  • 6
  • 37
  • 58
1
vote
1 answer

Default tab bar view?

I've had a look around and can't find any reference to default tab of a Tab Bar Controller in xCode. I would like the middle tab to be selected as the default when the app loads. Is there a way to do this? I've noticed that people are sating to…
Alex
  • 3,031
  • 6
  • 34
  • 56
1
vote
1 answer

I didn't get any notifications when I touched on tabbar items

I have UITabbarCoo=ntroller application. I added an observer and I'm waiting for any notifications. I didn't get any notifications when I touched on tabbar items. [self.tabBarController addObserver:self forKeyPath:@"selectedIndex"…
Voloda2
  • 12,359
  • 18
  • 80
  • 130
1
vote
3 answers

pop the root view(default) of second tab from the view controller of any other tab

i am having application consisting of both TabBarController and Navigation Controller.I am having two tabs as tabA and tabB. The default selecetd tab is 1(tabB) with view controller L(when the application finish its launching).Now user can navigate…
maddy
  • 4,001
  • 8
  • 42
  • 65
1
vote
1 answer

custom tab bar controller not working?

I am trying to build a custom tab bar controller but for some reason the views will not switch... The initial view is loaded properly. Here is my init method: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle…
thebiglebowski11
  • 1,451
  • 10
  • 41
  • 76
1 2 3
99
100