【发布时间】:2010-10-24 10:04:52
【问题描述】:
UITabBarController 是否可以在代码中选择选项卡?比如 UINavigationController 我们可以使用popViewController弹回rootViewController而不是按下返回按钮,那么如何在tabbarcontroller中实现呢?
【问题讨论】:
UITabBarController 是否可以在代码中选择选项卡?比如 UINavigationController 我们可以使用popViewController弹回rootViewController而不是按下返回按钮,那么如何在tabbarcontroller中实现呢?
【问题讨论】:
使用 UITabBarController 上的 selectedIndex 属性。更多信息可以在UITabBarController Class Reference找到。
controller.selectedIndex = 4;
或使用
[controller setSelectedIndex:4];
【讨论】:
self.tabController(tabController, didSelect: controller)自己调用它。有点hacky,但它有效。你应该为它归档一个雷达;设置索引应该自动调用它。