In my UIViewController, I have a non-editable attributed UITextView with scrolling enabled, and I would like to resize the height of the scrolling text to accommodate all screen size widths without having extra white space. I am using AutoLayout and set up outlets for the textview and its height constraint. In the view controller's viewDidLoad method I use the sizeThatFits method to update the textview height, but the resulting size is too small.
NSLog(@"INIT HEIGHT: %f, myTextView.frame.size.height);
CGSize sizeToFit =
[myTextView sizeThatFits: CGSizeMake(myTextView.frame.size.width, MAXFLOAT)];
myTextViewHeightConstraint.constant = sizeToFit.height;
NSLog(@"NEW HEIGHT: %f", myTextView.frame.size.height);
The log indicates the height was indeed changed from my default of 4000 to 2502, but with 2502 I only see about half of my text via scrolling. I am avoiding nesting the text view in a scroll view, as one solution suggests, since this is discouraged in documentation. What am I missing? Thanks in advance.