我有一个带有TabBar和选项卡的iPhone应用程序。每个选项卡都加载有UIViewControllers,我想要的特定选项卡是更改与选项卡关联的UIViewController。当我调用PresentViewController时,它会更改UIViewController,但还会隐藏我不想要的TabBar。
有人可以解释一下需要做什么吗?
谢谢
UITabBarController在适当命名为的属性中保留其视图控制器的集合viewControllers
。您可以在运行时修改它。有一些副作用可能适合您的应用程序,但是请务必阅读文档。
便捷方法(以及如何修改不可变数组的说明)如下所示:
- (void)replaceTabBarViewControllerAtIndex:(NSUInteger)index with:(UIViewController *)newVC {
NSMutableArray *newVCs = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
if (index < newVCs.count) {
newVCs[index] = newVC;
self.tabBarController.viewControllers = [NSArray arrayWithArray:newVCs];
}
}
用新的vc调用它,而不显示它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句