Skip to content

Instantly share code, notes, and snippets.

@squm
Last active January 2, 2016 11:29
Show Gist options
  • Save squm/8296990 to your computer and use it in GitHub Desktop.
Save squm/8296990 to your computer and use it in GitHub Desktop.
animates well
selectOptions = [NSMutableIndexSet new];
// …
- (UITableViewCell *)
tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
const NSUInteger row = indexPath.row;
// …
cell.accessoryType = [selectOptions containsIndex:row] ?
UITableViewCellAccessoryCheckmark :
UITableViewCellAccessoryNone;
// …
return cell;
}
- (void)
tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
const NSUInteger row = indexPath.row;
if ([selectOptions containsIndex:row]) {
[selectOptions removeIndex:row];
}
else {
[selectOptions addIndex:row];
}
[tableView reloadRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment