I am preparing a custom view which looks similar to the example shown in the screenshot. I add all user interface components (labels, text fields, radio buttons, ..) at runtime. To position the elements I use Autolayout constraints. This part works fine so far.
The number of elements varies from context to context. I wonder how I could use Autolayout constraints to dynamically resize the parent view (most likely the height of the view). The view constraints therefore should consider the height and margins defined for the currently attached subviews.
I've done this with the following setup:
The auto layout system satisfies these constraints by resizing the container to fit its contents.
Of course, you need to dynamically set the constraints as you alter the contents.