In my view controller, I have an UITextView. This textview is filled with a string. The string can be short or long. Depending on the length of the string, the height of the
First, disable UITextView's scrollable. Two options:
Create a UITextView and connect it with IBOutlet (TextView). Add a UITextView height constraint with default height, connect it with IBOutlet (TextViewHeightConstraint). When you set your UITextView’s text asynchronously you should calculate the height of UITextView and set UITextView’s height constraint to it. Sample code:
CGSize sizeThatFitsTextView = [TextView sizeThatFits:CGSizeMake(TextView.frame.size.width, MAXFLOAT)];
TextViewHeightConstraint.constant = sizeThatFitsTextView.height;