1医瘫、不需要canEditRowAtIndexPath方法侣肄,只要下面的方法就可以
2、如果需要有的Cell不能左滑醇份,可以設(shè)置return返回空數(shù)組稼锅,設(shè)置return nil 沒用
- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *closeAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"關(guān)閉" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
}];
closeAction.backgroundColor = colorRGB(255, 135, 0);
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"刪除" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
}];
deleteAction.backgroundColor = colorRGB(249, 52, 52);
UITableViewRowAction *deleteAction1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"刪除" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
}];
deleteAction1.backgroundColor = colorRGB(213, 210, 210);
if (indexPath.section == 0) {
return @[closeAction];
} else if (indexPath.section == 1) {
return @[deleteAction];
} else if (indexPath.section == 2) {
return @[deleteAction1];
}
return @[];
}