更改 TabBarItem 的 ViewController [英] Change ViewController for a TabBarItem

查看:34
本文介绍了更改 TabBarItem 的 ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为 UITabBarController 中的一个选项卡更改/替换 ViewContoller(和 View)?

Is it possible to change/replace ViewContoller (and View) for one of the Tabs in a UITabBarController?

我想从特定选项卡以任何顺序在 3 个不同的 ViewController 之间切换(这就是为什么 NavigationController 不可用).

I would like to switch between 3 different ViewControllers in any order from a specific Tab (that´s why NavigationController is not possible).

推荐答案

它们是使用 setViewControllers:animated: 设置的(大量)所以你可以做这样的事情.

They are set (in mass) using setViewControllers:animated: so you could do something like this.

// Assume tabController is the tab controller 
// and newVC is the controller you want to be the new view controller at index 0
NSMutableArray *newControllers = [NSMutableArray arrayWithArray:tabController.viewControllers];
[newControllers replaceObjectAtIndex:0 withObject:newVC];
[tabController setViewControllers:newControllers animated:YES];

希望有所帮助.

这篇关于更改 TabBarItem 的 ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆