当加载集合视图时,有没有办法隐藏特定的单元格?例如,该列表总共有10个项目.我希望集合视图显示9个项目,第二个项目将被忽略.目前,我正在进行
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if indexPath.item == 1 {
let item = list[indexPath.item] as? ChatEntity else {
let dummyCell = collectionView.dequeueReusableCell(withReuseIdentifier: "DummyCell", for: indexPath) as! DummyCell
dummyCell.setNeedsUpdateConstraints()
dummyCell.updateConstraintsIfNeeded()
return dummyCell
}
let cell = ....
...............
return cell
}
但它在第二项的位置显示空白.有没有办法在没有空白处的情况下查看列表?