Trey Pringle
Trey Pringle

Reputation: 141

Trigger UITabbarController Action from UIButton Touch

I have a general tabbed application in Swift. I would like to be able to trigger an action on the tabbarcontroller from a UIButton Touch within one of the view controllers.

The button is located in View Controller 2 and should trigger a segue back to view Controller 1 via the UITabbarController when touched.

enter image description here

Upvotes: 0

Views: 109

Answers (1)

Trey Pringle
Trey Pringle

Reputation: 141

Found the answer:

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

**use appropriate index for the tab you want to accesss

Upvotes: 1

Related Questions