Resolved: How to perform an unwind segue from a custom tableview cell?


I’m trying to trigger a unwind segue from a button that is inside a custom table view cell. But it won’t let me create the link between the exit and the view controller.


This sounds like a good job for a protocol/delegate pattern. What I would do is:
  1. Create your unwind segue by connecting it to the viewcontroller not to the tableViewCell. Assign it an identifier you can use later

  2. Create a protocol to which the MyViewController will conform

     protocol unwindHandler{
        func didRequestUnwind()
  3. Implement the protocol in the MyViewController

     extension MyViewController : unwindHandler{
         func didRequestUnwind(){
             performSegue(withIdentifier:"myUnwind",sender:nil)//execute the segue with identifier assigned in 0
  4. Assign the ViewController as the delegate to the tableViewCell in cellForRowAt in the datasource of the tableView

  5. Call delegate?.didRequestUnwind() in the didSelectRowAtIndexPath for the cell(s) you want to have that capability

If you have better answer, please add a comment about this, thank you!