-(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
// // 删除操作
[arr removeObjectAtIndex:indexPath.row];
[ta beginUpdates];
[ta deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
[ta endUpdates];
[ta reloadData];
NSLog(@"删除");
}];
action1.backgroundColor = [UIColor redColor];
UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"编辑" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
// 编辑操作
}];
return @[action1,action2];
}
(iOS开发)tableview自带的删除方法(8.0之后适用)
最新推荐文章于 2022-07-15 10:07:49 发布