Swipe To Delete TableView Row

后端 未结 8 980
暖寄归人
暖寄归人 2020-12-24 06:10

I have my array:

self.colorNames = [[NSArray alloc] 
initWithObjects:@\"Red\", @\"Green\",
@\"Blue\", @\"Indigo\", @\"Violet\", nil];

I\'ve

8条回答
  •  一向
    一向 (楼主)
    2020-12-24 07:11

    This is what worked for me

    -(void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
    
        if (editingStyle == UITableViewCellEditingStyleDelete){
            Comment *comment = [self.commentArray objectAtIndex:indexPath.row];
            dispatch_async(kBgQueue, ^{
                if([self.thePost deleteCommentForCommentId:comment.commentId]){
                    if (indexPath.row < self.commentArray.count) {
                        [self.commentArray removeObjectAtIndex:indexPath.row];
                    }
                    dispatch_async(dispatch_get_main_queue(), ^{
    
                        [self.tvComments reloadData];
                    });
                }
            });
        }
         [self.tvComments reloadData];
    }
    

提交回复
热议问题