【发布时间】:2021-02-26 14:09:28
【问题描述】:
我知道这个问题被问过几次,但其他解决方案对我不起作用。
我有这个模型:
var notifications = [Notification]()
Notification:
let user: User (name, profileimage, etc)
let items: [Movies] (movie has image, name, etc)
所以我在 tableview 中显示我的通知,每个单元格的顶部都有个人资料信息,collectionview 有下面的项目。
在我的 tableviewcell 中,我必须重新加载我的 collectionview 的数据才能显示正确的电影。我知道 reloadData 方法可能会导致这种滞后,但是有什么解决方案可以避免吗?
TableViewcell:
var notification: Notification! {
didSet {
collectionView.reloadData();
}
}
我也在tablecell里面试过这个东西,在willDisplayTableViewcell里面调用这个方法,但是一点用都没有:
func setCollectionViewDataSourceDelegate(forRow row: Int) {
collectionView.delegate = self
collectionView.dataSource = self
collectionView.reloadData()
}
图片是用翠鸟加载的,所以在我项目的其他地方没问题。
userProfileImage.kf.setImage(
with: URL(string: profileImage),
options: [
.processor(DownsamplingImageProcessor(size: CGSize(width: 175, height: 175))),
.scaleFactor(UIScreen.main.scale),
.transition(.fade(0.2)),
]
)
【问题讨论】:
标签: swift uitableview scroll uicollectionview