Created
November 17, 2014 23:42
-
-
Save benjaminsnorris/ab22ada42ba5dddc29c2 to your computer and use it in GitHub Desktop.
Edit Actions for Table View Row
This file contains hidden or 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
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { | |
UITableViewRowAction *removeButton = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Remove" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { | |
[self deletePlayerAtIndexPath:indexPath]; | |
self.game.startingNumberOfPlayers = @(self.game.startingNumberOfPlayers.integerValue - 1); | |
}]; | |
UITableViewRowAction *resetScoreButton = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Reset Score" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { | |
[self.game resetScoresForPlayer:[self.fetchedResultsControllerDataSource.fetchedResultsController objectAtIndexPath:indexPath]]; | |
}]; | |
resetScoreButton.backgroundColor = [UIColor primaryColorLight]; | |
return @[removeButton,resetScoreButton]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment