iphone - 以编程方式切换到 TabBar 选项卡 View ?

假设我的 iPhone 应用程序的一个选项卡 View 中有一个 UIButton,我想让它在 TabBarController 的选项卡栏中打开另一个选项卡。我将如何编写代码来做到这一点?

我假设我卸载现有 View 并加载特定选项卡 View ,但我不确定如何准确编写代码。

最佳答案

在 Swift 或 Objective-C 中尝试此代码

swift

self.tabBarController.selectedIndex = 1

Objective-C

[self.tabBarController setSelectedIndex:1];

https://stackoverflow.com/questions/5413538/

相关文章:

objective-c - xcode中Base SDK、iOS部署目标、Target、Projec

iphone - 静态库中的 Objective-C 类别

objective-c - 使用 Objective-C 在 iOS 9 中将状态栏文本颜色更改为浅

ios - 从 UITableView 单元格内的 url 异步加载图像 - 滚动时图像更改为错误图

objective-c - 为什么要使用 ivar?

objective-c - Xcode 5 : Code signing entitlement e

objective-c - 在objective-c中YES/NO,TRUE/FALSE和true/

ios - 如何查看 NSString 是否以某个其他字符串开头?

objective-c - NSAttributedString 的 boundingRectWit

ios - 如何手动弃用成员