For my application, I need to add several dynamic-sized UIViews to a global UIScrollView. I want the subviews to position themselves one on the top of the others.
To simplify and be able to reuse my subviews, I made them as separated ViewControllers that I insert into my global ScrollView inside a Container View. They all look alike: a title label, which has a fixed height, a button at the bottom, and in between, a CollectionView or a TableView which has a variable height, which are all embedded inside a ScrollView so that I can compute the size with the contentSize
The structure of the view is the following:
[ScrollView]
[Header view (fixed size)]
[Container View #1]
[Container View #2]
...
[/ScrollView]
I would like the global WebView to resize according to the items inside it, and the containerViews to resize according to the content of the main view of the VC they embed.
My problem is that I can't get the correct size of my subviews: the contentSize of the embedding ScrollView of the components is not correct: either the width or the height is incorrect.
I added constraints between the elements, which seem to work, but when I try to get the contentSize of the scrollview of the components, the height that I get is the size of the height constraint of the embedding container view, which is not logical, because the content inside the scrollview is much taller, thus the scrollview allows scroll