Search code examples
iosstoryboardnslayoutconstraint

Android Wrap content equivalent in story board in iOS?


I am trying to build a UI in iOS

  • Scroll View
    • UIButton
    • Image
    • UiTextView
    • UIButton

Now, the way I set up constraint is that Button and Images have constant width and height, and my UITextView, have equal width and leading edge set.

And now story board is complaining that my uiTextVIew doens't have a height.

My question is, since the content inside my uitextview is dynamic, and depending on the screen width, i believe it may fit more text per line or less.

Is there a height="wrap_content" equivalent in iOS storyboard that I could set to that text view?? Or is this something actually that I have to do in the code???

Thanks


Solution

  • Nope , there is no content-wrap equivalent in IOS , you have to give that textView an inital height in IB , then hook that height as IBOutlet and whenever you set a text to it do

    textViewHeight.constant = textView.contentSize.height