Difference between revisions of "UITabBarController"

From iPhone Development Wiki
Jump to: navigation, search
(fix my typo)
 
(2 intermediate revisions by 2 users not shown)
Line 7: Line 7:
 
A reverse-engineered code listing follows:
 
A reverse-engineered code listing follows:
  
<code>
+
<source lang="objc">
 
- (void)_setSelectedViewController:(UIViewController *) {
 
- (void)_setSelectedViewController:(UIViewController *) {
 
     if (_transientViewController == nil || _transientViewController == controller) return;
 
     if (_transientViewController == nil || _transientViewController == controller) return;
Line 20: Line 20:
 
         [[self moreNavigationController] setDisplayedViewController:nil];
 
         [[self moreNavigationController] setDisplayedViewController:nil];
 
      
 
      
     if (__UIApplicationLinkedOnOrAfter(4) && [[self delegate] respondsToSelector:@selector(tabBarController:didSelectViewController)])
+
     if (__UIApplicationLinkedOnOrAfter(4) && [[self delegate] respondsToSelector:@selector(tabBarController:didSelectViewController:)])
 
         [[self delegate] tabBarController:self didSelectViewController:controller];
 
         [[self delegate] tabBarController:self didSelectViewController:controller];
 
}
 
}
</code>
+
</source>
 +
 
 +
{{occlass|library=UIKit.framework|navbox=1}}

Latest revision as of 06:58, 1 February 2011

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];
}