menu

开发进行时...

crazy coder

Avatar

Three20框架中使用TabBarController的问题

使用Three20框架且使用TabBarController, 在每个Tab中使用TTNavigationController. 但有5以上Tab时,更多 选项卡中的详细将不能正确打开。

google到这是一个09年的BUG,现在也没有修复
http://groups.google.com/group/three20/browse_thread/thread/af2c5890e5e03fc1

@RoBak42发表:

I think, it is a problem with the additional moreNavigationController 
which is used when more than 5 tabs are used. 
When I put the marked lines (see ("// v--- from here" ...  "// ^-- to 
here" below) 
in TTNavigator.m's parentForController:parent: method, 
it works a little bit better. Nevertheless I am sure it doesn't fix 
the problem really, 
but I hope it is a hint for someone, who completly understands what's 
going on and is able to fix it. 
- (UIViewController*)parentForController:(UIViewController*)controller 
parent:(NSString*)parentURL { 
  if (controller == _rootViewController) { 
    return nil; 
  } else { 
    // If this is the first controller, and it is not a "container", 
forcibly put 
    // a navigation controller at the root of the controller 
hierarchy. 
    if (!_rootViewController && ![controller canContainControllers]) { 
      [self setRootViewController:[[[UINavigationController alloc] 
init] autorelease]]; 
    } 
    if (parentURL) { 
      return [self openURL:parentURL parent:nil animated:NO]; 
    } else { 
      UIViewController* parent = self.topViewController; 
      // v--- from here 
      if ([parent isKindOfClass:[UINavigationController class]]) { 
        if (parent.parentViewController != nil) 
          parent = parent.parentViewController; 
        if ([parent isKindOfClass:[UITabBarController class]]) { 
          parent = [(UITabBarController*)parent 
moreNavigationController]; 
        } 
      } 
      // ^---- to here 
      if (parent != controller) { 
        return parent; 
      } else { 
        return nil; 
      } 
    } 
  } 
} 

@Skotch:

1. I can navigate to the first level items on the more menu, but if I 
try to navigate deeper it doesn't seem to work. [solved by your 
change] 
2. If I have a more menu, and I enter into a item on the more menu, 
then the first icon on my tab bar now seems to show both icons. [not 
solved] 
3. Also, if I exit the app, then the code that tries to restore state 
gets confused, and it isn't able to reopen the item under the more 
menu. [not solved] 
Your change definitely solves the first one, but as you suggested, is 
not sufficient. If there is anyone who understand this code, please 
look into fixing this. Otherwise, I am avoiding the more menu for 
now. 

分析了很久,
修改了@RoBak42的一行代码搞定:

if ([parent isKindOfClass:[UITabBarController class]]) {
                parent = [[(UITabBarController *)parent moreNavigationController] topViewController];
            }