Last week I struggled with this rather basic problem of adjusting the height of a UIView dynamically.
TL;DR: the solution was to align the bottom edge of with a control with the view.
We use a custom UIView with a fixed height of 120px to display a separator, an image and text on its right. We also use FLKAutoLayout, which is where all these nice alignment methods come from.
This is obviously problematic for tall images and cropping art is a major offense. How do we dynamically calculate the height of the view based on the image and/or text height? Since the image is loaded dynamically, are we going to have to write some pretty involved code to wait until its height is known? Do we need to auto-size the label and calculate its height after it wraps over multiple lines?
The answer is that we don’t need to do any of this. With auto-layout we need to attach the image and the text to the bottom of the containing view.
With this constraint auto-layout seems to be smart enough to pick the tallest control to calculate the height of the view.