Linked Questions

Popular Questions

UITextView inside UIScrollView with AutoLayout

Asked by At

I am trying to place UITextView inside UIScrollView with AutoLayout with no luck. What I have tried is,

  • I placed UIScrollView inside the main view in Storyboard
  • I placed UITextView inside UIScrollView in Storyboard and disabled Scrolling Enabled
  • I set constraints (leading, trailing, top, bottom) on UIScrollView
  • I set constraints (top, leading, trailing, height) on UITextView
  • I created IBOutlet of height constraint of UITextView
  • I set a text (a lot of text which can cause scrolling) on UITextView in viewDidLoad()
  • I set a height constraint of UITextView with the code below. I have tried it right after setting text in viewDidLoad() and viewDidLayoutSubviews() with no luck

self.textViewHeightConstraint.constant = [self.textView sizeThatFits:CGSizeMake(self.textView.frame.size.width, FLT_MAX)].height;

UITextView is getting its height, but UIScrollView isn't. Is there anything I've missed?

Related Questions