【发布时间】:2019-03-15 06:05:29
【问题描述】:
我有一个双向滚动 collectionView,它有 50 个部分,每部分 10 个项目,每部分 3 个显示单元格,并用相同的数据数组填充 collectionView。 问题是每个部分中的 collectionView 重复数据,我想在出现的部分中向用户显示不同的数据。 请提供任何帮助! 这是我的代码:
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 50
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 10
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: contentCellIdentifier,
for: indexPath) as! UserCollectionCell
cell.userImageView.kf.setImage(with: URL.init(string: String().loadCorrectUrl(url:firebaseUsers[indexPath.row].image)))
cell.userNameLabel.text=firebaseUsers[indexPath.row].name
if(selectedIndexPaths.contains(indexPath) ){
cell.userBackgroudView.isHidden=false
}
else{
cell.userBackgroudView.isHidden=true
}
}
return cell
}
【问题讨论】:
-
如何在没有另一个 collectionview 的情况下实现双向滚动
标签: ios swift uicollectionview