OGeek|极客世界-中国程序员成长平台

标题: ios - 如何在 UINavigationController 中嵌入 UITabBarController? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:06
标题: ios - 如何在 UINavigationController 中嵌入 UITabBarController?

我想在 UINavigationController 中嵌入 UITabBarController。我找到了a similar question here on StackOverflow ,但我尝试的实现不允许我将 UIBarButtonItem 添加到 navigationItem.rightBarButtonItems

下面是我的实现截图。正在运行的应用程序中不显示“按钮 1”和“按钮 2”。任何想法我做错了什么?

UITabBarController inside UINavigationController screenshot



Best Answer-推荐答案


我认为您的“按钮 1”和“按钮 2”不可见,因为根导航 Controller 的导航栏重叠。
因此,您可以执行以下操作:
步骤 1. 创建一个 UITabBarController 子类并在 IB 中将其分配给您的标签栏 Controller 。
Step 2. 在 -viewWillAppear: 方法中只隐藏根导航 Controller 的导航栏

- (void)viewWillAppearBOOL)animated
{
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}

第 3 步:返回 Root View 时带回导航栏

- (void)viewWillDisappearBOOL)animated
{
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}    

关于ios - 如何在 UINavigationController 中嵌入 UITabBarController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36986985/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4