Replacde didDeselectRowAtIndexPath
with didSelectRowAtIndexPath
.
The delegate method you have written is didDeselectRowAtIndexPath
instead of didSelectRowAtIndexPath
.
According to apple, tableView:didDeselectRowAtIndexPath:
Tells the delegate that the specified row is now deselected.
and
tableView:didSelectRowAtIndexPath: Tells the delegate that the specified row is now selected.
So, what is happening is, when you click on a row, it becomes selected and turns gray and then when you click on the same or any other row, the previous one gets deselected because only one row is selected at once and hence calls this method to open the next view controller with the previous tapped row.