Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.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_Button - Fatal编程技术网

Ios uitableview重置删除按钮

Ios uitableview重置删除按钮,ios,iphone,uitableview,button,Ios,Iphone,Uitableview,Button,在我的uitableview中,当用户将模式设置为“编辑”并尝试删除一行时,我会进行一些验证以检查该行是否可以删除。如果没有,我希望将行重置为以前的状态,即不使用右侧的delete按钮,而只使用左侧的水平减号按钮 我将使用哪种方法执行上述操作?请尝试以下代码 - (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIn

在我的uitableview中,当用户将模式设置为“编辑”并尝试删除一行时,我会进行一些验证以检查该行是否可以删除。如果没有,我希望将行重置为以前的状态,即不使用右侧的delete按钮,而只使用左侧的水平减号按钮

我将使用哪种方法执行上述操作?

请尝试以下代码

- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

if(fails)
{
  [self.tableView reloadData];
  [super setEditing:YES animated:YES]; 
  [self.tableView setEditing:YES animated:YES];
}
试试这个代码

- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

if(fails)
{
  [self.tableView reloadData];
  [super setEditing:YES animated:YES]; 
  [self.tableView setEditing:YES animated:YES];
}

KingofBlis的回答将完成工作,不过这有点具体。此方法将设置删除确认的重置动画,并基本上“点击”删除编辑控件(重置确认的操作)


}])

Kingofblis的回答将完成这项工作,不过这有点具体。此方法将设置删除确认的重置动画,并基本上“点击”删除编辑控件(重置确认的操作)


}])

这将只重置需要重置的单元格

- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{
    if(fails)
    {
        [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    }
}

这将只重置需要重置的单元格

- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{
    if(fails)
    {
        [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    }
}