AutoLayout: two dynamic width UILabels; how to use preferredMaxLayoutWidth?

I have two labels next to each other in a custom View Table cell; the left is multi-line, one is one. I would like to take the desired label as much space as possible, the rest the rest and make a wrapper.

With Auto-Layout, I can only achieve this if I set the preferredMaxLayoutWidth value of the left label to a static value, for example. 150. Then it is wrapped as intended, and I can calculate the cell as follows:

[cell.leftLabel systemLayoutSizeFittingSize:UILayoutFittingExpandedSize].height; 

How can I avoid installing the preferredMaxLayoutWidth fix on the left label, since it is dynamic?

+6
source share

All Articles