tabBarController(_:displayedViewControllersFor:proposedViewControllers:)
Used with UITabGroup.managingNavigationController, this method allows the delegate to customize the displayed view controllers within the navigation stack for each level of selected tab. This method is called by the system if the selected tab in the UITabBarController belongs to or is in the hierarchy of a managing tab group (i.e. a UITabGroup with a non-nil managingNavigationController). By default, if this method is not implemented, the system will build the navigation stack by adding each tab’s viewController into the hierarchy, if one exists. This is especially useful to hide certain view controllers when transitioning between compact and regular size classes.
Declaration
optional func tabBarController(_ tabBarController: UITabBarController, displayedViewControllersFor tab: UITab, proposedViewControllers: [UIViewController]) -> [UIViewController]Parameters
- tabBarController:
The tab bar controller managed by the delegate.
- tab:
The tab for which the displayed view controllers is being requested for by its
managingTabGroup. Each tab in the selection hierarchy will be called once. - proposedViewControllers:
The proposed view controllers for the given tab. In general, the proposed view controller is a single-item array of the tab’s viewController. If other view controllers are pushed onto the navigation stack, they will be part of the last (leaf-most) tab’s
proposedViewControllerssuch that they are preserved between updates.
Return Value
A list of view controllers represented by the tab in the navigation stack.