0

I have a UITextView that's embedded into a UIScrollView. I would like the text view to not scroll and be exactly as high as required to show all of the text. So the width is fixed and I set the content insets to indent the text a bit.

How do I get the correct height? I tried to set the frame's height to the content height but still it scrolls.

Krumelur
  • 32,180
  • 27
  • 124
  • 263

1 Answers1

0

This should do the trick:

-(void)resizeTextView
{
    CGRect  frame = _textView.frame;
    frame.size.height = [_textView sizeThatFits:CGSizeMake(frame.size.width, INFINITY)].height;
    _textView.frame = frame;
}
David Berry
  • 40,941
  • 12
  • 84
  • 95