I have a problem of adjusting the UIView height in my project. I illustrated the project.
Let me explain about my project image.
Each Orange UIView has trailing, leading , top and bottom constraints and vertical spacing to each UIView.
But, I add "Height" to each UIView because if I don't add, it gives error and add the "Height" warning.
In UIView2, I add 3 Container Views. Each Container Views has 3 View Controllers. (Data 1 View, Data 2 View, Data 3 View)
I embed Collection View inside in each views.
The problem is that in Data 3 View has many collection View cell data. So, the height of Orange UIView should be increase according to the collection view content.
Currently, I just add fixed height constant (height:800) if users click on the Data 3 segmented control button.
But, I don't want to set fixed height like this.
I've been trying to solve this problem since last week. I could not solve this till now.
Can anyone help me explain in step by step please? Because I have no idea of what should I do.
Since
UITableView
orUICollectionView
inherit fromUIScrollView
they basically do not have anintrinsicContentSize
.You have two ways to make the same height as the content size (the space that you can scroll):
intrinsicContentSize
method to return thecontentSize
and thesizeThatFits:
method as well