I need to create an UIView
dynamically and show it as a cell in UITableView
or UIScrollView
.
How can I do this without manually calculating the height of the view (summing up the height of all elements) ?
Example: I programatically add 2 images and 10 texts that are stacked vertically on each other in a UIView. I take this UIView and put it in a cell content view, or scroll view. How do I make sure that the view expands itself so it shows all the subviews inside ?
EDIT:
I guess the proper way would be to set the vertical and horizontal constraints for each subview from top to bottom (including the bottom constraint for the last element).
The problem is that I can't set the height constraint for each element in the dynamic UIView, as these elements have a dynamic height too.