From iPhone Development Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

UITabBarController is a class used for managing a UITabBar within a UIViewController hierarchy.

-[UITabBarController _setSelectedViewController:]

This method is the main method used for managing selection. It's called, sometimes indirectly, when you tap an item in the tab bar or change the selected controller programatically (even via -setSelectedIndex:). However, popping back to the root controller and similar tasks are handled by other methods.

A reverse-engineered code listing follows:

- (void)_setSelectedViewController:(UIViewController *) {
    if (_transientViewController == nil || _transientViewController == controller) return;
    if (_selectedViewController == controller) return;
    BOOL moreController = [[[self moreNavigationController] moreViewControllers] containsObject:controller];
    [self _setSelectedTabBarItem:[controller tabBarItem]];
    [self transitionFromViewController:_selectedViewController toViewController:controller];
    if (moreController && [self _allowSelectionWithinMoreList])
        [[self moreNavigationController] setDisplayedViewController:nil];
    if (__UIApplicationLinkedOnOrAfter(4) && [[self delegate] respondsToSelector:@selector(tabBarController:didSelectViewController:)])
        [[self delegate] tabBarController:self didSelectViewController:controller];