1

I have 2 UIView for my app, one main view, and one detailed view. From the main View, I open a detailed detailed view, where I have a table, with a segue. I want to return to the main view when clicking in one of the cells of this table. As I want to return some data, I set up a segue, but yet I was not able to run the code in the segue, and then return to the main view. It works when adding a button (exit), but not when using the code

I already checked this: Using delegates to transfer data from one TableView to another and lots of others, but I didn't found somebody who has the same problem.

Do you have any idea how to solve this?

Thanks a lot, Alexander

Alexander Ko
  • 195
  • 18

1 Answers1

0

In Storyboard, you can connect an unwind segue from the cell in your detail view to the unwind method you added in your main view controller.

Don't add any code to the detail's didSelectCellAtIndexPath: as it will not run before the segue.

Instead, set any properties you want to return in prepareForSegue.

The unwind segue will be called when the cell is selected, and the main view controller will be able to access those returned properties in its unwind method.

  • Thanks for this tip. I added this unwind method to my main screen, but the problem is that when i want to ctrl - drag from my table to the exit-icon, it seems like the exit icon is disabled. When I do the same form a button on the same view, it works... – Alexander Ko Sep 08 '15 at 06:05
  • That's because you're control-dragging from the wrong object. You need to segue from the prototype cell, not from the table. –  Sep 08 '15 at 06:08