0

I am working on an app in Swift 4 and I am trying to unwind a segue. I have a Table View Controller, When the user selects a cell, the segue happens to a navigation controller which has a relationship root view controller with another controller I have UIViewController. In the UIViewController I have a UIButton inside Navigation Items, I have unwind set with the UIButton by selecting the button and dragging to exit and I have the unwind code inside the UITableViewController like so:

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
            if segue.identifier == "segueRSVP" {
            }
        }



    @IBAction override func unwind(for unwindSegue: UIStoryboardSegue, towardsViewController subsequentVC: UIViewController) {
        print("Here")
    }

But nothing happens, it doesn't even get triggered.

Here are my screenshots:

enter image description here

enter image description here

enter image description here

3
  • Put the tableview in the navigation controlller and then you won’t even need the unwind segue or the button. Commented Nov 9, 2017 at 19:19
  • You cant see in my screenshots, but there is a navigation controller above the tableview controller....so it goes navigation controller -> tableview -> navigation controller -> UIViewController Commented Nov 9, 2017 at 19:42
  • Then delete the second navigation controller and use a show segue to show the rsvp scene Commented Nov 9, 2017 at 20:01

2 Answers 2

2

Add this unwind to your RSVP controller:

@IBAction func unwindToThisViewController(segue: UIStoryboardSegue) {
    print("IM BACK")
}

Then control + drag the button in your detail controller up to the exit and select the method: unwindToThisViewController

Just tested this on xcode swift 4 and it should work

I'm not sure why, but when I "overrode" unwind, it didn't work for me either, so I set up my own ibaction

Sign up to request clarification or add additional context in comments.

1 Comment

Oh hmm remove this: override func prepare. and remove @IBAction override func unwind and see if that does it
0

In my case, was tagging the swift unwind func with @objc keyword.

@objc func unwindToThisViewController(segue: UIStoryboardSegue) { ... }

Hope this works.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.