tableview侧滑删除的时候,删除最后一行的时候报错。

删除的代理方法中实现如下:- (void)tableView:(UITableView )tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath )indexPath{

if (editingStyle == UITableViewCellEditingStyleDelete) {
    NSIndexPath * path = [_businessTableview indexPathForCell:_memoryCell];
    
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        //[self DelegateRecode:[NSString stringWithFormat:@"%@",IDArr[indexPath.row]]];
        dispatch_async(dispatch_get_main_queue(), ^{
            [resultArr removeObjectAtIndex:path.row];
            
            [_businessTableview beginUpdates];
            [_businessTableview deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
            _memoryCell = nil;
            [_businessTableview endUpdates];
            if(resultArr.count == 0){
            [_businessTableview deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationLeft];
            }
        });
    });
}

}

报错如下:
2016-09-08 16:03:25.803 SUOTAO[5986:2554341] * Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.12/UITableView.m:1716

其中:数据源是我从后台得到的数组,section 返回的是1,写的死数据。

阅读 3.1k
1 个回答

应该是直接删section吧,你的代码似乎会在删row的时候就报错。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题