3

A custom view with overridden intrinsicContentSize property is added to a UIStackView

 override var intrinsicContentSize: CGSize {
    return CGSize(width: 100, height: 44)
  }

Storyboard shows that the UIStackView is now missing a height property.

Although the custom view is drawn successfully in the simulator, I still want to get rid of this storyboard error message. Thank you

Myrick Chow
  • 332
  • 1
  • 6
  • 16
  • Take a look at https://stackoverflow.com/questions/13727589/how-do-you-make-interface-builder-respect-a-custom-views-intrinsic-content-size – Dusan.czh Nov 07 '22 at 14:23

1 Answers1

0

It looks like you are missing the constraint of the stack view not the view added to the stack. Check the constraints of the stack.

  • Can you please explain more about the constraint that needs to be added? – Karthick Ramesh Aug 31 '18 at 02:37
  • 1
    The constraint of the stackview are `UIStackView.Leading = SafeArea.LeadingMargin` `UIStackView.Top = SafeArea.Top` `UIStackView.Trailing = SafeArea.TrailingMargin` The height of UIStackView could be calculated by the arranged subview(s). – Myrick Chow Aug 31 '18 at 02:37
  • You need a constraint for the height of your stack view. Either a heigh constraint or a bottom constraint. If you want it to grow by the content you can follow https://stackoverflow.com/a/40256540/7932898 – Jorge Luna Sep 01 '18 at 01:05