iOS 8 beta 2: ''tableView:editActionsForRowAtIndexPath:"

July 6, 2014 ยท View on GitHub

  • (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"More" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { // show UIActionSheet }]; moreAction.backgroundColor = [UIColor greenColor];

    UITableViewRowAction *flagAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Flag" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) { // flag the row }]; flagAction.backgroundColor = [UIColor yellowColor];

    return @[moreAction, flagAction]; }

/*

  • EDIT on 06.07.2014 because of some confusion if 'tableView:commitEditingStyle:forRowAtIndexPath:' is needed.
  • It IS needed. */
  • (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { // No statement or algorithm is needed in here. Just the implementation }