Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unwind segue doesn't work in Swift 3 and iOS 10

I'm trying to test unwind segue in iOS 10 and Swift 3.

I made a simple app like this: enter image description here

enter image description here

I add code for segue in TableViewController class and connect "Cancel" button and Exit on Table View Controller Scene:

@IBAction func unwindToRootViewController(segue: UIStoryboardSegue) {
    print("Unwind to Root View Controller")
}

but my simple segue doesn't work. What am I doing wrong?

like image 316
IlyaGutnikov Avatar asked Oct 07 '16 11:10

IlyaGutnikov


1 Answers

As can be seen in the comments above the problem was this:

I add code for segue in TableViewController class

The unwind segue has to be in your "outer" ViewController, not the TableViewController.

This article gives a very nice introduction to unwind segues.

like image 100
pbodsk Avatar answered Oct 05 '22 02:10

pbodsk