具有不明确高度的 UIViews

UIViews with ambiguous height

我在 UIView 中有一个集合视图。我需要让集合视图与 UIView 通信,它的高度应该取决于集合视图内的内容量。

然后我需要让这个 UiView(白框)知道它应该有多高。我相信我在我的设置函数中正确地完成了这部分,但我不确定(我是编码新手)。

I need to have the collection view communicate to the UIView the height it should be depending on the amount of content inside the collection view

该高度是布局的 collectionViewContentSize 高度。但请注意,此高度可以超过 window 的大小,因为这是一个滚动视图 - 重点是内容的大小可以大于集合视图的大小。因此,最好问问自己 为什么 你认为你需要这样做。