I am working on a project on which I have to preselect a particular cell.
I can preselect a cell using -willDisplayCell, but I can\'t deselect it when t
If you want to select any table cell with the first click and deselect with the second, you should use this code:
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.selectedIndexPath &&
[indexPath compare:self.selectedIndexPath] == NSOrderedSame) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
self.selectedIndexPath = nil;
}
else {
self.selectedIndexPath = indexPath;
}
}