I’m currently building an app that uses the same countryPickerTableView in three different places with slightly different behaviour, so I would need a way to connect three different unwind segues to the tableview. The problem is that the cell only allows me to pick one unwind Action. Is there a solution to this?
Asked
Active
Viewed 321 times
1
-
Please provide some code. – Christoph Oct 04 '17 at 14:50
-
you have view controllers attached with navigation controller and based on some conditions you want to go to certains screen backwards..? Is that what you are looking for.. – Anil Kumar Oct 04 '17 at 14:51
1 Answers
1
Add segue to ViewController not from Cell. Drag from ViewController to exit Button and add segue, then add identifier. And then add method in ViewController
self.performSegue(withIdentifier: "IDENTIFIER", sender: self)

maxkoriakin
- 337
- 3
- 7
-
In which action or method should I put "self.performSegue(withIdentifier: "IDENTIFIER", sender: self)"? I tried creating an IBAction to put it in but since I do not seem to be able to connect a tableViewCell to an action nothing will trigger it. I then tried adding it to tableView(_:didSelectRowAt:) but that didn't work either. – Diez Nobach Oct 05 '17 at 09:42
-
@DiezNobach You put it in didSelectRowAt, but before you connect this unwindSegue. Drag it from ViewControllerButton(yellow button on the top of the image) to exitButton( rightButton on image) and add all of segues. Then Choose segue in storyboard and add identifier to it – maxkoriakin Oct 05 '17 at 09:50
-
Thanks, this helped me one step in the right direction! Now I got another problem instead. Before I sent data back through a prepare(forSegue:) in the countryPickerViewController. Now that does not work anymore. Should I send the data back with the unwindSegue instead? Tried that but couldn't get it to work. Do you know the best way to solve this? – Diez Nobach Oct 05 '17 at 11:34
-
@DiezNobach in prepareForSegue write for each controller, that destination for your unwindSegue if let destination1 = segue.destination as? "YOUR_DESTINATION_CONTROLLER" {} – maxkoriakin Oct 05 '17 at 11:44