我有一个集合视图。我需要按顺序显示不同宽度的单元格。根据需要显示前 4 个单元格,但之后连续第 5 个图像消失,其他单元格显示但未以所需方式显示。但它没有显示在模拟器中。滚动集合视图时视图会扭曲。请任何人在 swift 3 中帮助我。
如果要resizeUICollectionViewCell
尝试实现这个方法,frame
里面的设置cellForRowAt
是错误的。
func collectionView(_ collectionView: UICollectionView!, layout _: UICollectionViewLayout!, sizeForItemAtIndexPath indexPath: IndexPath!) -> CGSize {
if indexPath.row%3 == 0 {
return CGSize(width: 172, height: 120)
} else {
.....
}//switch, if, whatever
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句