iPhone更改按钮点击上的选项卡栏项目

发布于 2024-08-26 05:03:49 字数 89 浏览 2 评论 0原文

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

怎么做呢?

I have 4 tabs in my iphone application. When user will click a button in tab-1, I want to move/switch user to another tab suppose tab-2.

How to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岁月染过的梦 2024-09-02 05:03:49

您可以使用

[self.tabBarController setSelectedIndex:tabIndex];

其中 tabIndex 是要切换到的选项卡的索引。

You can use

[self.tabBarController setSelectedIndex:tabIndex];

where tabIndex is the index of the tab you want to switch to.

少年亿悲伤 2024-09-02 05:03:49

还可能指出,如果您在视图内,则应该使用 super 而不是 self。

Might also point out that if you are inside a view, you should use super instead of self.

假情假意假温柔 2024-09-02 05:03:49

Swift 3.0 版本的 @Jasarien 答案:

self.tabBarController?.selectedIndex = tabIndex

其中 tabIndex 是您要切换到的选项卡的索引。

Swift 3.0 version of @Jasarien answer:

self.tabBarController?.selectedIndex = tabIndex

where tabIndex is the index of the tab you want to switch to.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文