gpt4 book ai didi

ios - 带有 beginUpdates() 的 UITableView 弹跳

转载 作者:行者123 更新时间:2023-12-01 17:12:26 28 4
gpt4 key购买 nike

我使用典型的组合 CoreData - NSFetchedResultsController - UITableViewController。当我使用时:

func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
self.tableView.beginUpdates()
}
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
self.tableView.endUpdates()
}

通过更新数据源中的一项(没有插入或删除),有时 tableView 会无缘无故地上下跳动。

如果我有几个单元格,不足以填满表格 View ,它就不会反弹。

如果我有更多的单元格来滚动 tableview,它不会反弹。

但是,如果我有足够的单元格来填充表格 View ,这就是它反弹的地方。

如果我删除 beginUpdates()endUpdates(),就没有随机反弹,但是我失去了 begin/endUpdates() 的优势。

A preview can be seen here or over here

是什么原因造成的?以及如何修复它?

最佳答案

在 iOS 11 类似问题上,替换为 [tableView performBatchUpdates:nil completion:nil];解决问题..

关于ios - 带有 beginUpdates() 的 UITableView 弹跳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48005287/

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