代码之家  ›  专栏  ›  技术社区  ›  Thomas Joulin

在基于Interface Builder的TabBar应用程序中处理更多导航控制器

  •  0
  • Thomas Joulin  · 技术社区  · 15 年前

    我仍然不清楚如何以及何时使用界面生成器。我有一个基于tabbar的应用程序,其中添加了6个导航控制器。我不想有6个选项卡,我想3加上一个“更多”选项卡,允许用户配置他想要的选项卡。

    IB有什么办法吗?如果没有,我如何从IB转移到基于代码的tabbar(前提是我已经设置了一个类TabBarController来处理shouldAutoRotate:)

    提前谢谢!

    1 回复  |  直到 15 年前
        1
  •  -1
  •   Thomas Joulin    15 年前

    我解决了我的问题。因为我已经指定了 TabBarController 在选项卡栏控制器的IB中,我添加了以下内容:

    NSMutableArray *customizeable = [[NSMutableArray alloc] init];
    for (id controller in tabBarController.customizableViewControllers)
    {
        if ([controller isKindOfClass: [MyCustomizeable class]])
            [customizeable addObject:controller];
    }
    tabBarController.customizableViewControllers = customizeable;
    [customizeable release];
    

    只是吼叫:

    [window addSubview:tabBarController.view];
    

    ApplicationDelegate

    多亏了 http://www.mactech.com/articles/mactech/Vol.25/25.03/iPhoneProductivityApplicationsPart1/

    请注意,我可以用这些行来完成这项工作:

    NSMutableArray *customizeable = [[NSMutableArray alloc] init];
    tabBarController.customizableViewControllers = customizeable;
    [customizeable release];
    

    但我想控制哪些选项卡可以重新排序