【发布时间】:2020-04-19 05:30:10
【问题描述】:
如何在表格视图单元格内创建像这样具有不同单元格大小的集合视图,以及在集合视图单元格内的图像需要从 url 单元格 下载
我尝试了下面的代码,但最后 2 个小单元格上升了,并且当从 url 集合视图下载的图像直到手动触摸集合视图才加载时
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let cVWidth = collectionView.frame.width
let biggerCellWidth = (cVWidth / 2.5) - 5
if indexPath.row == 2 || indexPath.row == 3 {
let testValue:CGFloat = 3
return CGSize(width: (biggerCellWidth / 2) - testValue , height: (biggerCellWidth / 2) - testValue )
}
return CGSize(width: biggerCellWidth, height: biggerCellWidth)
}
【问题讨论】:
-
你应该先尝试一下。你可以在网上找到很多文章
-
我添加了尝试过的代码,
-
但最后 2 个小单元的单元位置不正确
标签: ios swift uitableview uicollectionview uicollectionviewcell