Search code examples
iosuiviewautolayoutios-autolayoutccuiviewwrapper

Wrapper does not take it's Intrinsic Content Size as sum of it's children and constraints between them


I am creating popup that measures it's size (here only height) from the its content.

Popup consists of two half (top and bottom). I have decided to wrap top half into separate wrapper view for clean code, so I have added UILabels, UIImages etc. into it in the separate method, but now I am facing problem with it.

Their size for AutoLayout is 0! So, I have a size of popup less than needed:

Not enough size

But if I remove wrapper then everything is OK:

Normal size

I feel that it is enough data for iOS to render it correctly, but I don't know the command to force iOS to calculate size of wrapper basing on sizes of its subviews and constraints.

I have tried invalidateIntrinsicContentSize on the wrapper, but didn't help.

I am marking up from the code, so I don't forget to set Translates autoresizing masks into constraints to false for child views.


Solution

  • Ok, It is figured out that I forgot to joint top and bottom of wrapper with top of top view and bottom of bottom view respectively.