[英]iOS TableView inside of a CollectionView sometimes shows incorrect data
I have a collectionView where I show a list of comments in a tableView. 我有一个collectionView,在其中我在tableView中显示注释列表。 I see that the tableView data is not the correct one when the collectionView is scrolled.
当滚动collectionView时,我看到tableView数据不是正确的数据。
I tried to remedy that using prepareForReuse() which did not work. 我试图通过使用prepareForReuse()进行补救,但这是行不通的。 Here is my code :
这是我的代码:
override func prepareForReuse() {
super.prepareForReuse()
imageView.image = UIImage()
commentsTableView = UITableView()
}
I would appreciate if someone can suggest a solution for this. 如果有人可以提出解决方案,我将不胜感激。
Thanks. 谢谢。
Assign all your properties to nil. 将所有属性分配为nil。
override func prepareForReuse() {
imageView.image = nil
commentsTableView = nil
super.prepareForReuse()
}
But make sure that your properties is optional. 但是请确保您的属性是可选的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.