Dynamic intrinsicContentSize really not possible?

I want to make a custom view whose content layout and height is dependent on the frame width. The docs for intrinsicContentSize of a UIView say this:


"This intrinsic size must be independent of the content frame, because there’s no way to dynamically communicate a changed width to the layout system based on a changed height, for example."


This is demonstrably false, since UILabel does exactly this behind the scenes. Before it was automatic for UILabel to update the preferredMaxLayoutWidth, it was also possible through manual updates to the preferredMaxLayoutWidth. Granted, UILabel (and UIImageView for similar reasons I'm sure) can be finicky and hard to work with because of the difficulty of knowing their size up front without a fixed width. But it can work most of the time, even in dynamic height UITableViewCells where the initial size reported by intrinsicContentsize based on a frame width is often incorrect because the final table width isn't known until after the intrinsicContentSize is called for. It appears intrinsicContentSize is never called a second time for a subview of a table cell, even if it is invalidated.


I've tried a number of approaches to make this work, even ones I'm not comfortable with (like walking up the view hierarchy to get the table cell or table and telling them to update their constraints and layout) just to see if I could get any clues to a working approach.


Outside of setting a value similar to preferredMaxLayoutWidth, I don't want to move any extra responsiblity for figuring out the view's size up into a superview because that doesn't make for a clean, reusable custom view. I tried using the preferredMaxLayoutWidth approach but once intrinsicContentSize is called for a view, it is never called again as far as I can tell, even if the view has its intrinsicContentSize invalidated or its superviews are told to update their constraints. UITableViewCells appear to get size and height constraints that do not change in response to such calls.


Does anyone have experience with this issue?

Dynamic intrinsicContentSize really not possible?
 
 
Q