【问题标题】:iOS put a TabbarViewController into a NavigationController but the navigationBar is niliOS 将 TabbarViewController 放入 NavigationController 但 navigationBar 为 nil
【发布时间】:2013-08-06 04:00:49
【问题描述】:

A 是 TabbarViewController 的子类

A *a = [[A alloc] init];

B *b = [[B alloc] init];
C *C = [[C alloc] init];

NSArray *viewControllers = [NSArray arrayWithObjects:b,c, nil];
[a setViewControllers:viewControllers];

UINavigationController *nv =[[UINavigationController alloc] initWithRootViewController:a];
nv.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:nv animated:YES completion:nil];

在上午:我发现 a.navigationController.navigationBar 是 nil 不知道为什么?

【问题讨论】:

  • 您是否尝试将 TabBarController 放入 NavigationController 中?请写下你的实际课程,而不是 A、B、C。
  • @Stas 是的,A 是 TabbarViewController 的子类,我想将 A 放入 navigationController。

标签: ios uinavigationcontroller uinavigationbar


【解决方案1】:

通常,您应该为 TabBarController 的每个选项卡创建多个 NavigationController 对象。

当您创建导航界面时,您需要决定您打算如何使用导航界面。因为它对您的数据强加了一个总体组织,所以您应该只以以下特定方式使用它:

直接安装为窗口的根视图控制器。

将其安装为标签栏界面中标签的视图控制器。

将其安装为拆分视图界面中的两个根视图控制器之一。 (仅限 iPad)

从另一个视图控制器模态显示它。

从弹出窗口中显示它。 (仅限 iPad)

如果您仍需要“导航控制器中的 TabBarController”功能,请阅读 thisthis SO 问题以找到合适的解决方案。

【讨论】:

    猜你喜欢
    • 2013-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-07
    • 1970-01-01
    • 2020-05-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多