Last active
January 2, 2016 11:29
-
-
Save squm/8296990 to your computer and use it in GitHub Desktop.
animates well
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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