IOS uitableviewcell 向左滑动删除编辑等

时间:2023-03-08 21:28:53
IOS uitableviewcell 向左滑动删除编辑等

主要实现这个方法就好了

-(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{

return @[

[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:NSLocalizedString(@"编辑", nil) handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

  //点击编辑的具体超作

}],

[UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:NSLocalizedString(@"删除", nil) handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

  //点击删除的具体超作

}]

];

}

在返回的数组当中还可以添加更多的按钮   不建议写太多3个上限