Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在UITableView中删除行,但不要使用删除按钮_Ios_Iphone_Uitableview_Nsindexpath - Fatal编程技术网

Ios 在UITableView中删除行,但不要使用删除按钮

Ios 在UITableView中删除行,但不要使用删除按钮,ios,iphone,uitableview,nsindexpath,Ios,Iphone,Uitableview,Nsindexpath,我有一个问题,我想删除UITableView中的行,但不使用滑动按钮删除。我想要调用函数removeCellafter条件。我的问题是无法删除UITableView中的第一行,因为我不知道要删除的行的get indexPath 如果我滑动删除按钮,它工作得很好但我不想使用删除按钮。 - (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle for

我有一个问题,我想删除UITableView中的行,但不使用滑动按钮删除。我想要调用函数
removeCell
after条件。我的问题是无法删除UITableView中的第一行,因为我不知道要删除的行的get indexPath

如果我滑动删除按钮,它工作得很好但我不想使用删除按钮。

- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
    deleteindexPath = indexPath;
    /*[_tableView beginUpdates];

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }
    [_tableView endUpdates];*/
    [self removeCell];
}
removeCell():

我尝试设置
deleteIndexPath=[\u tableView indexPathForCell:cell]
cellforrowatinexpath()
中,但不工作,崩溃

你有什么建议吗

试试这个

-(void) removeCell
{    
    [_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:deleteIndexPath] withRowAnimation:UITableViewRowAnimationFade];
    //Now remove data from your tableArray also..
    [_tableView reloadData];
}

那么您想如何调用这个
removeCell
method?您有哪些节?您使用哪个数组来填充tableview?
-(void) removeCell
{    
    [_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:deleteIndexPath] withRowAnimation:UITableViewRowAnimationFade];
    //Now remove data from your tableArray also..
    [_tableView reloadData];
}