【发布时间】:2018-05-21 05:31:29
【问题描述】:
根据屏幕截图,我将有一个包含几个单元格(带有颜色)的大集合视图。除绿色的单元格外,所有单元格将在视图中仅显示一次。绿色的单元格将显示一组用户。
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if indexPath.item == 0{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: topfeatureCellIndent, for: indexPath) as! topFeatureCell
//configure if needed
return cell
}else if indexPath.item == 1{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: userCellIdent, for: indexPath) as! featureUserContainerViewCell
cell.featureUsers = featureUser
cell.selectUserdelegate = self
return cell
}else if indexPath.item == 2{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ticketLabelIdent, for: indexPath) as! ticketLabelCell
return cell
} else if indexPath.item == 3{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: whosgoingIdent, for: indexPath) as! whoGoingCell
cell.config(withTimer: timeleft)
return cell
}
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: allUserCellIdent, for: indexPath) as! allUserCell
let index = indexPath.item - 4
let user = allPartyUserArr![index]
cell.config(withUser: user)
return cell
我需要显示最后一个单元格的方式是通过实现上面的代码,但我认为它不正确,因为如果我想在显示所有单元格后添加其他单元格,有没有更好的方法来使单元格出列正常吗?
【问题讨论】:
-
为什么不对不同的类型使用不同的部分?
-
我是 swift 新手,你能告诉我如何在不同的部分显示它们吗?谢谢兄弟
-
@Amit 我不认为本教程提供的信息与我想要的相似,因为它们主要关注标题和选择。
-
@MuhammadNayab 有关如何正确实施部分的任何指南?
标签: ios swift uicollectionview