UITableView Detect Selected Cell?

Josh Kahane picture Josh Kahane · Nov 30, 2010 · Viewed 19.3k times · Source

I have multiple UITableViews in my app, is there a method of detecting which cell/row the user has selected in that column?

Also is it possible to programatically deselect a cell/row?

Thanks.

Answer

Jeremy Fuller picture Jeremy Fuller · Nov 30, 2010

Get currently selected index path for a table:

NSIndexPath *path = [tableView indexPathForSelectedRow];

Deselect currently selected row:

[tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];