Resizing UITextView to fit height of its content can be achieved like this:
CGRect frame = _textView.frame;
frame.size.height = _textView.contentSize.height;
_textView.frame = frame;
For example, if you need to know the CGSize that is taken by your
NSString if rendered on a single line, use
CGSize sz = [_textView.text sizeWithFont:_textView.font] then adjust your frame given this size value.
If you need to know the size taken by your text if rendered on multiple lines, wrapping it if the text reaches a given width, use
sizeWithFont:constrainedToSize:lineBreakMode: instead, etc.
2) You may also be interested in the
sizeToFit methods of UIView.
The first one returns the CGSize (that fits in the given CGSize passed in parameter) so that your UITextView can display all your text. The second actually do the resizing, adjusting the frame for you.