I want to create a table that the user can select and deselect using a checkmark:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath { ...; cell.selectionStyle = UITableViewCellSelectionStyleNone; } - (void)tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { ...; newCell.accessoryType = UITableViewCellAccessoryCheckmark; ...; }
I tried to remove the checkmark by clicking on the cell with the check again, but this requires 2 clicks, not one.
If I set the default selection style when I click on the selected row, it removes the blue highlight; clicking again, it removes the check mark.
I also tried some conditional statements in didSelectRowAtIndexPath , but they only respond to a second click.
What causes the problem and how to fix it?
source share