我有一个collectionView,我在tableView中显示评论列表。当 collectionView 滚动时,我发现 tableView 数据不正确。
我尝试使用prepareForReuse()来解决这个问题,但没有成功。这是我的代码:
override func prepareForReuse() {
super.prepareForReuse()
imageView.image = UIImage()
commentsTableView = UITableView()
}
如果有人能为此提出解决方案,我将不胜感激。
谢谢。
最佳答案
将所有属性分配为零。</p>
override func prepareForReuse() {
imageView.image = nil
commentsTableView = nil
super.prepareForReuse()
}
但请确保您的属性是可选的。
关于CollectionView 内的 iOS TableView 有时会显示不正确的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50808679/