masaldana2 masaldana2 - 1 year ago 123
iOS Question

How to segue multiple view controllers programmatically using swift 3.0

I'm getting an error:

has no segue with identifier 'dest1''

and what I did was:

  • route(ctrl+drag) in storyboard viewcontroller -> dest1, viewcontroller -> dest2

  • have an action button in viewController.swift

  • set storyboard ids to "dest1" and "dest2"

    @IBAction func Parameters(_ sender: AnyObject) {
    self.performSegue(withIdentifier: "dest1", sender: nil)

  • Prepare for segue

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "dest1" {
    if let svc = segue.destination as? secondViewController {
    } else if segue.identifier == "dest2" {
    if let svc = segue.destination as? reverbViewController {

What am I missing?

Answer Source

From your description, you have set storyboard ids to "dest1" and "dest2", whereas you need to set segue identifiers. Click on the segue itself in IB, and set it's property.

Storyboard identifiers are used when creating the view controller using code...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download