Nesting Manual Layout within Auto Layout views

We've had some success nesting Manual Layout (ML) (i.e., views that implement layoutSubviews() and sizeThatFits(...)) within Auto Layout (AL) views. This seems to work fine if the AL parent defines the size for the ML child. The ML child doesn't seem to participate in defining its size at all. In fact, sizeThatFits(...) is not called at all during the layout pass.

This isn't surprising given the differences in the two systems. Ideally the sizeThatFits: method would get called with whatever the AL solver decided was appropriate, but I understand that this is complicated by chicken and egg problems - it's not this simple.

For the case in which the ML child wants to define its own size without constraints (i.e., using CGFloat.greatestFiniteMagnitude size for sizeThatFits) I was hoping to leverage the intrinsicContentSize along with content hugging and compression resistance priorities to communicate size information up to the AL parent.

This...almost works. I'm getting frames that seem to be taking the intrinsic size into account, but aren't exactly what I'd expect.

Are there any other techniques I should be exploring here?


We are having the same issue with a Collection View Cell. The cell can be collapsed or open and auto layout only does open. (Obviously since it is using all of the text.) I thought we cold use sizeThatFits(...) to override the auto layout for the closed case, but it never gets called. It's one of the last things we need to fix to support dynamic text sizes.

Has there been an answer for this somewhere, or is there a better way to limit the collection view flow layout?
Nesting Manual Layout within Auto Layout views
 
 
Q