gpt4 book ai didi

ios - 移动行(在 :to:) doesn't work if the UITableView has many items

转载 作者:行者123 更新时间:2023-11-28 06:23:28 25 4
gpt4 key购买 nike

我正在尝试在选择行后在部分之间移动项目。这是我用于将项目从第 0 节移动到第 1 节的代码:

tableSource[indexPath.section].tableItems.remove(at: indexPath.row)
tableSource[1].tableItems.insert(data, at: 0)
tableView.moveRow(at: indexPath, to: IndexPath(row: 0, section: 1))
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: {
self.tableView.reloadRows(at: [IndexPath(row: 0, section: 1)], with: UITableViewRowAnimation.automatic)
})

DispatchQueue 用于在动画后更新行。

如果所有项目都适合屏幕或第 1 部分可见,则它会完美运行。否则,我得到的行为就像您删除一行并将其添加到另一个索引时一样。

最佳答案

这是因为如果单元格不可见,UITableView 不知道在哪里设置动画

关于ios - 移动行(在 :to:) doesn't work if the UITableView has many items,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42665992/

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