How to deselect a selected UITableView cell?
use this code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //Change the selected background view of the cell. [tableView deselectRowAtIndexPath:indexPath animated:YES]; }
Swift 3.0:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { //Change the selected background view of the cell. tableView.deselectRow(at: indexPath, animated: true)}
Use the following method in the table view delegate's didSelectRowAtIndexpath
(Or from anywhere)
[myTable deselectRowAtIndexPath:[myTable indexPathForSelectedRow] animated:YES];
Try this:
for (NSIndexPath *indexPath in tableView.indexPathsForSelectedRows) { [tableView deselectRowAtIndexPath:indexPath animated:NO];}