Skip to content

Instantly share code, notes, and snippets.

@scheinem
Last active September 26, 2019 05:23
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save scheinem/e36835db07486e9f7e64 to your computer and use it in GitHub Desktop.
Save scheinem/e36835db07486e9f7e64 to your computer and use it in GitHub Desktop.
iOS 8 beta 2: ''tableView:editActionsForRowAtIndexPath:"
- (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
}
@jellyZ
Copy link

jellyZ commented Sep 1, 2014

good~

@MVakas
Copy link

MVakas commented Sep 17, 2014

Worked for me like a charm.

@omgbbqhaxx
Copy link

İs this code work with ios 7 or 6 ? or only work with ios8 + ?

@scheinem
Copy link
Author

@omgbbqhaxx Only 8.0 beta 2 and above

@guomingman
Copy link

but why we should add

  • (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    // Nothing is needed here
    }
    I debug it ,and didn't execute this API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment