gpt4 book ai didi

ios - tableView.reloadRows(at : [indexPath], with : . none) 会像这样崩溃吗?

转载 作者:行者123 更新时间:2023-11-28 10:38:07 24 4
gpt4 key购买 nike

我正在尝试弄清楚 Fabric 中的一个错误:

Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (40) must be equal to the number of rows contained in that section before the update (20), plus or minus the number of rows inserted or deleted from that section (1 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out). specialized NewInboxViewController.tableView(UITableView, didSelectRowAt : IndexPath)

发生在 didSelectRow:AtIndexPath 的这一行:

tableView.reloadRows(at: [indexPath], with: .none)

TableView 行为是:

  • 查看模型加载 20 行
  • 当用户滚动到 TableView 的 70% 时,我们再加载 20 行,isDownloading bool 值切换为 true,调用完成时设置为 false,然后重新加载 TableView <
  • can commit edits 为 false 而 isDownloading 为 true,否则用户可以滑动删除行
  • 当用户拉动刷新时,我们清除单元格拉动数组中存储的所有内容,并替换为 API 调用中最近的 20 个项目(已编辑)

最佳答案

您告诉 TableView 重新加载一行,但您向数据模型添加了 20 行新行。这就是错误的意思。它说:

"before you called reloadRows there had been 20 rows in the data model. Now I see there are 40 rows in the data model but you are only telling me to reload (insert and delete) 1 row."

您应该使用包含 20 个新索引路径的数组调用 tableView.insertRows(at:),每个新添加的行一个。

关于ios - tableView.reloadRows(at : [indexPath], with : . none) 会像这样崩溃吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52280189/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com