【发布时间】:2017-11-14 00:55:21
【问题描述】:
当我实现以下代码时:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize{
let cellW = (ScreenWidth - 10 - 10 - 30) / 4
return CGSize(width: cellW, height: cellW * 1.5 )
}
通过使用 sizeForItemAt 方法,我可以绘制我想要的框架,但是我的自定义 collectionview 单元格无法更新,我错过了哪里,请帮助我!!
【问题讨论】:
-
将图像的约束添加到前导/尾随/顶部到 superView?并为底视图添加缺少的约束?
-
我确实为我的 imageview 和 label 添加了约束,这似乎是 collectionview 单元格的问题,也许我在 awakefromNib 中遗漏了一些东西? imgur.com/a/6N9qC
-
imgur.com/a/XOVTn 这是我的故事板集合视图单元格框架
-
你写的是你在类声明中实现了 UICollectionViewDelegateFlowLayout 吗?
-
是的,我确实实现了 UICollectionViewDelegateFlowLayout 委托,以便我可以绘制该区域(请参阅调试视图:imgur.com/a/TyjOr)
标签: ios swift3 uicollectionview uicollectionviewcell