1

segue screenshot

Screenshot above is 2 segue; from (view1 or view2) to view3

When creating the unwind segue, how do I get it to call the right @IBAction method?

    // code in view1.swift
    @IBAction func backview1(segue: UIStoryboardSegue) {

    }

    // code in view2.swift
    @IBAction func backview2(segue: UIStoryboardSegue) {

    }

Should I add code in view3.swift? How do I code the back segue method in view3.swift in order to go back to origin view?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
WoderMan
  • 53
  • 1
  • 12

2 Answers2

1

If you name the function you are returning to the same in both viewControllers, then you will be returned to the one that called VC3.

For example, put this in both VC1 and VC2:

@IBAction func backFromVC3(segue: UIStoryboardSegue) {

}

Then, when you create your unwind segue, just choose backFromVC3 from the pop-up.

vacawama
  • 150,663
  • 30
  • 266
  • 294
1

To create a segue you can do it by CTRL clicking on an UI element, for instance, a UIButton to the destination UIViewController:

segue

Then on both of your source UIViewController that you want to go back to from and unwind segue you need to implement the following method:

 @IBAction func unwindSegue(segue: UIStoryboardSegue) { }

After doing this you can again CTRL drag to perform an unwind segue:

unwind

Diogo Antunes
  • 2,241
  • 1
  • 22
  • 37