Gundam Gundam - 1 year ago 84
Swift Question

I segue from two viewControllers to one viewController. How to unwind segue to the caller?

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?

Answer Source

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.