ios - NSInternalInconsistencyException 修复

标签 ios swift

更新方法:

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        initialData[indexPath.section].remove(at: indexPath.row)

        tableView.deleteRows(at: [indexPath], with: .fade)

    } else {

    }
}

错误:

reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).

我该如何解决这个问题?

最佳答案

非常仔细地阅读您的控制台告诉您的内容。

您的数据源提示说,在您使用 removeAtIndexPaths() 删除一行后,它没有预期的行数。

确保您在删除/添加的内容以及相应更改的数据源中保持完整性。此外,请确保在主队列上进行这些更改。

祝你好运! :)

关于ios - NSInternalInconsistencyException 修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45538966/

相关文章:

ios - AFNetworking 的 requestWithMethod :path:parameters: Returning NSMutableURLRequest That Doesn't Persist

iphone - 如何从左向右移动uiview,反之亦然

swift - Web 服务以 swift 方式返回 XML

ios - 如何确定磁力计是否需要对 CoreMotion 引用系进行校准?

ios - 如何强制 parse.com 将对象添加为字符串而不是数组?

iPhone 应用程序失去互联网连接(NSURLConnection 未返回)

ios - 如果 TableViewCell 有大量数据要显示,则在 UITableViewCell 中添加自定义按钮的最佳方式。使用 swift

ios - UI 图像/多 View Controller

ios - WebCore : Worker: EXC_BAD_ACCESS when connecting Safari debugger to an Xcode 8. 3 项目

ios - 具有滚动功能的大量文本的 UIAlertController?