【发布时间】:2021-03-25 23:31:08
【问题描述】:
我在 UITableViewCell 中有 UICollectionView。如果我将 CollectionviewCell 的大小设置为 custom 并提供固定宽度,那么它可以正常工作。
但如果我将其设为 自动 并在委托中分配大小,则它不起作用。它采用默认宽度,即 50。
你能帮帮我吗? 谢谢
改变大小的代码:
extension BeInspiredTVC : UICollectionViewDelegate , UICollectionViewDelegateFlowLayout{
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: UIScreen.main.bounds.width - 50, height: 224)
}
}
我想要一个全宽的 Collectionviewcell,但我得到了如下图所示。
【问题讨论】:
-
您能否通过图片展示您需要实现的目标
-
是的。当然。让我编辑问题。
-
请查看问题中的图片
-
可以添加更改大小的代码
-
已添加。请检查。
标签: ios swift uitableview uicollectionview storyboard