I need to perform back button action when I tap on the cell in 'didSelectRowAt indexPath' between 2 TableViewControllers

Viewed 55

I just wanted to perform back button action when I'm selecting a cell.

I have one TableView with 4 prototype cells with buttons etc, embed in NavigationController. And when I tap on the button in one of the cells, I perform segue to the next TableView controller.

On the next TableViewController I choose the cell, click on it, and then I need to perform this back button action, only in didSelectRowAt indexPath method, on the second TableViewController

I can perform segue, but it will not work as I needed. I tried with dismiss it goes to the root view, not worked.

My target is to perform exactly the same animation like with the back button. Just go back to the first tableview controller.

Any Ideas, please?

1 Answers

Do popViewController instead of dismiss on your didSelectRowAtIndexPath method

self.navigationController?.popViewController(animated: true)
Related