swift - 从 UIButton 触摸触发 UITabbarController 操作

标签 swift uitabbarcontroller

我有一个通用的 Swift 选项卡式应用程序。我希望能够通过 View Controller 之一内的 UIButton Touch 触发 tabbarcontroller 上的操作。

该按钮位于 View Controller 2 中,触摸时应通过 UITabbarController 触发返回 View Controller 1。

enter image description here

最佳答案

找到答案:

@IBAction func buttonClicked(sender: AnyObject) {
    self.tabBarController?.selectedIndex = 0
}

**为您要访问的选项卡使用适当的索引

关于swift - 从 UIButton 触摸触发 UITabbarController 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32212542/

相关文章:

ios - Tabbar Design 在 iPhone X 上显示不正确

ios - 如何使用 UserDefaults 来保存登录状态?

ios - 在按钮上快速单击打开新屏幕

ios - 一旦平移手势开始,交互式滑动菜单就会完成[Swift]

ios - 单击选项卡栏更多按钮时获取两个导航栏

ios - 推送到新的 UIViewController 后强制再次调用 viewDidLoad

swift - 如何在 Swift 中使用 UnsafeMutablePointer<OpaquePointer>?

swift - 任务完成后重定向

ios - 禁用特定选项卡栏项目排序的最佳方法

ios - 如何使用 subview Controller 中的按钮单击来更改选项卡栏项目标题