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中的数据
    }
}

 

posted @ 2015-04-04 10:42  apem  阅读(133)  评论(0编辑  收藏  举报