Santos
Santos

Reputation: 1

Unwind doesn't work and I have the correct code

I have this segue in a navigation view controller. This has a ViewController called SectionsTableViewController, and this has a bar button item that I linked to exit action and called "close" action segue.

Image of my StoryBoard

And in my ViewController I have this cose:

class ViewController: UITableViewController {
    @IBAction func close(segue: UIStoryboardSegue) {
        print("Hey")
    }
}

But it doesn't work.

Upvotes: 0

Views: 295

Answers (2)

Nima Yousefi
Nima Yousefi

Reputation: 817

The unwind segue code needs to be in the view controller you're unwinding back to, as opposed to the one with the Stop button. So if your view controllers normally move in this direction:

StartingViewController -> SectionsTableViewController

you want to put the unwind segue in StartingViewController.

Putting the unwind in the wrong view controller and not connecting it via Interface Builder are the only possible ways this can go wrong.

Upvotes: 1

ericl
ericl

Reputation: 321

Did you hook up the method to the object in the storyboard (control + drag to Exit)? Connecting to method in storyboard

Upvotes: 0

Related Questions