-
-
Save scheinem/e36835db07486e9f7e64 to your computer and use it in GitHub Desktop.
| - (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 | |
| } |
@r-peck @siancu Did you implement tableView:commitEditingStyle:forRowAtIndexPath:?
Just insert the following code into your TableViewController.m and it should work:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
// Nothing is needed here
}Thanks! This has been super helpful! One question, though: when selecting one of the options presented, the row doesn't return to its original position. Any thoughts on how to get it back it its resting position?
EDIT: Solved by adding [self.tableView setEditing:NO] to the action handler per suggestion by @marksands https://twitter.com/marksands/status/488430429612277761
This doesn't work for insert indicator rows for me. Only delete indicators. I'm hoping this works in iOS 8 final. I need the control space in my app.
good~
Worked for me like a charm.
İs this code work with ios 7 or 6 ? or only work with ios8 + ?
@omgbbqhaxx Only 8.0 beta 2 and above
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.
Let's wait for the next drop then, hopefully it'll work better :-)