UItableView 编辑

时间:2023-03-10 03:52:09
UItableView 编辑
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"删除";
} - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
} - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
debugMethod();
NSLog(@"%ld,%ld", indexPath.section, indexPath.row);
if (editingStyle == UITableViewCellEditingStyleDelete) {
//移除数据源的数据
NSMutableArray *mutableArr = [self.goodsListArray mutableCopy];
[mutableArr removeObjectAtIndex:indexPath.row];
self.goodsListArray = [mutableArr copy];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];//移除tableView中的数据
}
}