我目前有许多 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/