【发布时间】:2015-09-14 17:43:06
【问题描述】:
我有一个集合视图,每个集合视图单元中都有一个图像。对于任何给定的帧/屏幕尺寸,我只想有 3 个单元格。我该如何实现这一点。我写了一些基于this post的代码
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let numberOfCell = 3
let cellWidth: CGFloat = [[UIScreen mainScreen].bounds].size.width/numberOfCell
return CGSizeMake(cellWidth, cellWidth)
}
但它不起作用并给出错误。最好的方法是什么。
【问题讨论】:
标签: ios swift uicollectionviewcell