pragma mark -
- (BOOL)tableView:(UITableView )tableView canEditRowAtIndexPath:(NSIndexPath )indexPath {
return YES;
} - (UITableViewCellEditingStyle)tableView:(UITableView )tableView editingStyleForRowAtIndexPath:(NSIndexPath )indexPath {
return UITableViewCellEditingStyleDelete;
} - (void)tableView:(UITableView )tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath )indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[_dataSource removeObjectAtIndex:indexPath.row];
[_actionTBView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
}
} (NSArray )tableView:(UITableView )tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
//设置删除按钮
UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@”删除” handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
[_dataSource removeObjectAtIndex:indexPath.row];
[_actionTBView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
NSLog(@”删除”);
}];//设置置顶按钮
UITableViewRowAction *showRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@”置顶” handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
NSLog(@”置顶”);
}];
//设置背景颜色
showRowAction.backgroundColor = [UIColor blueColor];
return @[deleteRowAction,showRowAction];
}