5

我的 iphone 应用程序中有 4 个选项卡。当用户单击选项卡 1 中的按钮时,我想将用户移动/切换到另一个选项卡,假设选项卡 2。

怎么做?

4

3 回答 3

12

您可以使用

[self.tabBarController setSelectedIndex:tabIndex];

tabIndex您要切换到的选项卡的索引在哪里。

于 2010-03-25T17:10:40.490 回答
3

还可能会指出,如果你在一个视图中,你应该使用 super 而不是 self。

于 2010-04-10T23:02:47.310 回答
2

@Jasarien 的 Swift 3.0 版本回答:

self.tabBarController?.selectedIndex = tabIndex

tabIndex您要切换到的选项卡的索引在哪里。

于 2017-04-04T14:33:29.273 回答