Instance Method

setViewControllers:animated:

Sets the root view controllers of the tab bar controller.

Declaration

- (void)setViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers animated:(BOOL)animated;

Parameters

viewControllers

The array of custom view controllers to display in the tab bar interface. The order of the view controllers in this array corresponds to the display order in the tab bar, with the controller at index 0 representing the left-most tab, the controller at index 1 the next tab to the right, and so on.

animated

If YES, the tab bar items for the view controllers are animated into position. If NO, changes to the tab bar items are reflected immediately.

Discussion

When you assign a new set of view controllers at runtime, the tab bar controller removes all of the old view controllers before installing the new ones. When changing the view controllers, the tab bar controller remembers the view controller object that was previously selected and attempts to reselect it. If the selected view controller is no longer present, it attempts to select the view controller at the same index in the array as the previous selection. If that index is invalid, it selects the view controller at index 0.

This method also sets the value of the customizableViewControllers property to the contents of the viewControllers parameter.

See Also

Managing the View Controllers

viewControllers

An array of the root view controllers displayed by the tab bar interface.

customizableViewControllers

The subset of view controllers managed by this tab bar controller that can be customized.

moreNavigationController

The view controller that manages the More navigation interface.