-(NSArray<UITableViewRowAction *>*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewRowAction * rowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
MultiUserDataModel * model = dataArray[indexPath.row];
[self RErequesteDeleteURL:model];
if (isDeleteSuc) {
[dataArray removeObjectAtIndex:[indexPath row]];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationFade];
}
NSLog(@"删除");
}];
UITableViewRowAction * rowActionChange = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"修改" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"修改");
}];
rowAction.backgroundColor =[UIColor redColor];
rowActionChange.backgroundColor = [ChangeColor hexStringToColor:@"D2D2D2"];
NSArray * arr = @[rowAction,rowActionChange];
return arr;
}
本文介绍如何在iOS应用中为UITableView配置删除与修改行操作。通过UITableViewRowAction自定义样式及处理逻辑,实现了从数据源中移除指定项并更新UI的功能。
484

被折叠的 条评论
为什么被折叠?



