James James - 10 months ago 43
iOS Question

Swift create 'universal' segue in tab bar app

I'm a swift newbie and I've got a simple question which I hope someone can help me figure out.

I have a multi-tab app. I created some segues from the tab view controllers on the Stopryboard. I've given the segues identifiers and I'm calling them from my Tab1ViewController code using

performSegueWithIdentifier("tab1ToMyTarget", sender: sender)
no problem.

However, I'd like to be able to call the segue from any of the app's tabs without creating new segues from the other tabs' view controllers (i.e. I don't want to create
- I presume there's a better way!).

My question: Do I create these 'universal' segues on the tab bar view controller (e.g.
) (and if so how do I call it from one of my tab view controllers)? ...or...

Do I keep the segue from a single tab view controller (
) and call that segue from a sibling tab view controller somehow?


First, set the view controller that you want to go to's storyboard Id. Then run this:

let vc = storyboard.instantiateViewControllerWithIdentifier("someViewController")
self.presentViewController(vc, animated: true, completion: nil)