uitabbarcontroller - 在 tabBar 中隐藏一个项目?

标签 uitabbarcontroller

我目前有许多 viewControllers 通过 Storyboard 与我的 tabBarController 有关系。鉴于某些设置,我想以编程方式使某个 viewController 隐藏或可见。我可以隐藏整个 tabBar,但这不是我想要的。我一直在玩 Xcode 并搜索互联网,但找不到解决方案。以下内容对我不起作用!

[[self.tabBarController.tabBar.items objectAtIndex:2] setHidden:YES];

最佳答案

使用类似的代码来解决问题。

NSMutableArray *newTabs = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
[newTabs removeObjectAtIndex: 3];
[newTabs removeObjectAtIndex: 2];
[self.tabBarController setViewControllers:newTabs];

关于uitabbarcontroller - 在 tabBar 中隐藏一个项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21106666/

相关文章:

ios - 如何通过有条件地加载 UIViewController 的 Storyboard添加 UITabBarItem

ios - Swift:如何使用快速操作从 AppDelegate 访问某个 TabBar 选项卡?

ios - 在 UITabBarController 之间传递 UIImage

ios - 选项卡栏 Controller - 在选项卡栏中添加更多项目看起来很乱

ios - 在不显示选项卡栏的情况下执行到另一个导航 Controller 的转场

ios - -hidesBottomBarWhenPushed 在导航 Controller 中使用时会导致问题

ios - 为什么我的 UIAlertController 直到我第二次按下它的选项卡时才出现?

cocoa-touch - 如何从头开始制作标签栏应用程序

ios - 两个 Storyboard,都包含 TabBarControllers。如何在他们之间进行segue?

swift - 呈现 UITabBarController 的最佳实践