iphone - 更改 TabBarItem 的 ViewController

标签 iphone uiviewcontroller uitabbarcontroller

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

我想从特定选项卡以任意顺序在 3 个不同的 ViewController 之间切换(这就是导航 Controller 不可能的原因)。

最佳答案

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

// 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];

希望有帮助。

关于iphone - 更改 TabBarItem 的 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5303787/

相关文章:

iphone - 如何释放 CGImageCreateWithImageInRect 关联的内存

objective-c - 从 UIView 的 subview 获取 UINavController?

ios - UITabBarController setSelectedIndex 性能低下

ios - 如何在不使用 IB 的情况下使用自定义 UITabBar 类创建 UITabBarController?

swift - UINavigationController 到 UITabBarController

iphone - 使用 CATransition 从右向左转换并返回?

iphone - UISplitViewController 以编程方式

iOS 服务器到服务器通知

uiviewcontroller - 水平分隔符 NavBar IOS 7

swift - 如何使用 SWRevealViewController 从 Swift 中的 UITabBarItem 打开侧边菜单