【问题标题】:how can i stretch collectionView height in tableViewCell?如何在 tableViewCell 中拉伸 collectionView 的高度?
【发布时间】:2021-08-02 16:33:14
【问题描述】:
我想在 tableView 中拉伸 collectionView 的高度。
作为 gitHub App 的标签(下图),
当collectionViewCell的宽度超过collectionView的宽度时,
我想在新行中设置collectionViewCell
要在新行中设置单元格,我尝试使用 flowlayout。
但它并没有增加高度。只是可以在collectionView中滚动。 ????.
可惜tableView的高度没有增加
最好的方法是什么?????
【问题讨论】:
标签:
ios
swift
tableview
collectionview
【解决方案1】:
SRP-Achiever 的这种方法应该可行。
override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {
collectionView.layoutIfNeeded()
collectionView.frame = CGRect(x: 0, y: 0, width: targetSize.width , height: 1)
return collectionView.collectionViewLayout.collectionViewContentSize
}