Trigger UITabbarController Action from UIButton Touch
我在Swift中有一个常规的选项卡式应用程序。 我希望能够从其中一个视图控制器中的UIButton Touch触发tabbarcontroller上的操作。
该按钮位于View Controller 2中,并且在触摸时应通过UITabbarController触发搜索返回到View Controller 1。
找到了答案:
1 2 3 | @IBAction func buttonClicked(sender: AnyObject) { self.tabBarController?.selectedIndex = 0 } |
**为要访问的标签使用适当的索引