【发布时间】:2022-06-16 09:37:08
【问题描述】:
我最近更新到运行 iOS 15.5 模拟器的 Xcode 版本 13.4.1。我注意到在 iOS 15.5 模拟器上运行我的项目时,在加载带有 uicollectionviews 的 uitableviewcells 时出现以下错误。
[Assert] UITableView internal inconsistency: cell prefetched for IP(0,6) already stored for IP(0,5).
而 uitableviewcells 似乎在滚动时偶尔会消失。但是,当我在 iOS 13 模拟器上运行它并且表格视图正确加载且没有问题时,这不会发生。它似乎发生在包含 UICollectionView 的 uitableviewcells 上。
这是代码中的一个 sn-p:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "TestTableViewCell") as? TestTableViewCell else {fatalError()}
cell.collectionView.registerNibArray(withNames:["TestCollectionViewCell"])
cell.collectionView.delegate = self
cell.collectionView.dataSource = self
cell.collectionView.reloadData()
return cell
}
在最近的 iOS 版本中,uitableview 预取似乎发生了变化,任何解决方案都会很有帮助。
【问题讨论】:
-
这是一个非常糟糕的方法。您应该将集合视图逻辑(注册单元、委托、数据源等)放在单元类本身中。没有看到minimal reproducible example 就无法确定,但很可能是导致您的问题的原因。
标签: ios swift xcode uitableview