【发布时间】:2018-08-03 19:33:29
【问题描述】:
我目前正在编写我的应用程序的主页,这是一个带有标题的UICollectionViewController。
在标题中,我有很多Labels 和Buttons。
由于设置了约束,我想要一个动态高度,但我没有找到如何做到这一点或在 stackoverflow 上没有任何答案......
- 使用 Firebase 获取数据
- 将数据发送到 UICollectionReusableView
- 标签已在其中更新
所以流程是这样的:
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let headerViewCell = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "Header", for: indexPath) as! WodCollectionReusableView
headerViewCell.wod = self.wod // pass the info
headerViewCell.layoutIfNeeded()
return headerViewCell
}
如果您知道是否有一种方法可以做到这一点,就像我们可以为细胞做的那样,那就太棒了。
【问题讨论】:
标签: swift swift3 uicollectionview