UITabBarControllerDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 2.0 and later.
Companion guide
Declared in
UITabBarController.h
Related sample code

Overview

You use the UITabBarControllerDelegate protocol when you want to augment the behavior of a tab bar. In particular, you can use it to determine whether specific tabs should be selected, to perform actions after a tab is selected, or to perform actions before or after the user customizes the order of the tabs. After implementing these methods in your custom object, you should then assign that object to the delegate property of the corresponding UITabBarController object.

All of the methods in this protocol are optional. For more information on how to use and configure tab bar controllers and their delegates, see View Controller Programming Guide for iOS.

Tasks

Managing Tab Bar Selections

Managing Tab Bar Customizations

Overriding View Rotation Settings

Supporting Custom Tab Bar Transition Animations

Instance Methods

tabBarController:animationControllerForTransitionFromViewController:toViewController:

Called to allow the delegate to return a UIViewControllerAnimatedTransitioning delegate object for use during a noninteractive tab bar view controller transition.

- (id<UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController animationControllerForTransitionFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
Parameters
tabBarController

The tab bar controller whose view controller is transitioning.

fromVC

The currently visible view controller.

toVC

The view controller intended to be visible after the transition ends.

Return Value

The UIViewControllerAnimatedTransitioning delegate object responsible for managing the tab bar view controller transition animation.

Availability
  • Available in iOS 7.0 and later.
Declared In
UITabBarController.h

tabBarController:didEndCustomizingViewControllers:changed:

Tells the delegate that the tab bar customization sheet was dismissed.

- (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed
Parameters
tabBarController

The tab bar controller that is being customized.

viewControllers

The view controllers of the tab bar controller. The arrangement of the controllers in the array represents the new display order within the tab bar.

changed

A Boolean value indicating whether items changed on the tab bar. YES if items changed or NO if they did not.

Discussion

You can use this method to respond to changes to the order of tabs in the tab bar.

Availability
  • Available in iOS 2.0 and later.
Declared In
UITabBarController.h

tabBarController:didSelectViewController:

Tells the delegate that the user selected an item in the tab bar.

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
Parameters
tabBarController

The tab bar controller containing viewController.

viewController

The view controller that the user selected. In iOS v3.0 and later, this could be the same view controller that was already selected.

Discussion

In iOS v3.0 and later, the tab bar controller calls this method regardless of whether the selected view controller changed. In addition, it is called only in response to user taps in the tab bar and is not called when your code changes the tab bar contents programmatically.

In versions of iOS prior to version 3.0, this method is called only when the selected view controller actually changes. In other words, it is not called when the same view controller is selected. In addition, the method was called for both programmatic and user-initiated changes to the selected view controller.

Availability
  • Available in iOS 2.0 and later.
Declared In
UITabBarController.h

tabBarController:interactionControllerForAnimationController:

Called to allow the delegate to return a UIViewControllerInteractiveTransitioning delegate object for use during an animated tab bar transition.

- (id<UIViewControllerInteractiveTransitioning>)tabBarController:(UITabBarController *)tabBarController interactionControllerForAnimationController:(id<UIViewControllerAnimatedTransitioning>)animationController
Parameters
tabBarController

The tab bar controller participating in the interactive, animated transition.

animationController

The noninteractive animation controller

Return Value

The UIViewControllerInteractiveTransitioning delegate object responsible for managing the user interaction in an animated tab bar transition.

Availability
  • Available in iOS 7.0 and later.
Declared In
UITabBarController.h

tabBarController:shouldSelectViewController:

Asks the delegate whether the specified view controller should be made active.

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
Parameters
tabBarController

The tab bar controller containing viewController.

viewController

The view controller belonging to the tab that was tapped by the user.

Return Value

YES if the view controller’s tab should be selected or NO if the current tab should remain active.

Discussion

The tab bar controller calls this method in response to the user tapping a tab bar item. You can use this method to dynamically decide whether a given tab should be made the active tab.

Availability
  • Available in iOS 3.0 and later.
Declared In
UITabBarController.h

tabBarController:willBeginCustomizingViewControllers:

Tells the delegate that the tab bar customization sheet is about to be displayed.

- (void)tabBarController:(UITabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray *)viewControllers
Parameters
tabBarController

The tab bar controller that is being customized.

viewControllers

The view controllers to be displayed in the customization sheet. This list typically contains all custom view controllers you added but does not include some standard controllers, such as the one that manages the More tab.

Availability
  • Available in iOS 3.0 and later.
Declared In
UITabBarController.h

tabBarController:willEndCustomizingViewControllers:changed:

Tells the delegate that the tab bar customization sheet is about to be dismissed.

- (void)tabBarController:(UITabBarController *)tabBarController willEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed
Parameters
tabBarController

The tab bar controller that is being customized.

viewControllers

The view controllers of the tab bar controller. The arrangement of the controllers in the array represents the new display order within the tab bar.

changed

A Boolean value indicating whether items changed on the tab bar. YES if items changed or NO if they did not.

Discussion

This method is called in response to the user tapping the Done button on the sheet but before the sheet is dismissed.

Availability
  • Available in iOS 3.0 and later.
Declared In
UITabBarController.h

tabBarControllerPreferredInterfaceOrientationForPresentation:

Called to allow the delegate to provide the preferred orientation for presentation of the tab bar controller.

- (UIInterfaceOrientation)tabBarControllerPreferredInterfaceOrientationForPresentation:(UITabBarController *)tabBarController
Parameters
tabBarController

The tab bar controller that is asking the delegate object for the preferred presentation orientation.

Return Value

The preferred orientation for presenting the tab bar controller.

Availability
  • Available in iOS 7.0 and later.
Declared In
UITabBarController.h

tabBarControllerSupportedInterfaceOrientations:

Called to allow the delegate to provide the complete set of supported interface orientations for the tab bar controller.

- (NSUInteger)tabBarControllerSupportedInterfaceOrientations:(UITabBarController *)tabBarController
Parameters
tabBarController

The tab bar controller that is asking the delegate object for the supported interface orientations.

Return Value

One of the UIInterfaceOrientationMask constants that represents the set of interface orientations supported by the tab bar controller.

Availability
  • Available in iOS 7.0 and later.
Declared In
UITabBarController.h