sudo sudo - 1 year ago 406
iOS Question

Large Text Being Cut Off in UITextView That is Inside UIScrollView

I'm having a serious problem that I just can't seem to fix and it's driving me insane for the last two days. I have searched far and wide and I can't find a solution, even though I have tried many.

I have a UITextView inside a UIScrollView. I am able to dynamically resize the UITextView inside the scrollview to display the text. But when the UITextView contains very large text it gets cut off when I scroll almost to the end. However, the UIScrollView's frame is still being sized correctly.

I read these posts: this this and many similar ones.

The UIScrollview and UITextview are both created in the xib using AutoLayout.

Here is my current code and a screenshot as you can see the blank spot in the screenshot should be filled with text. please help.

enter image description here

- (void)viewDidAppear:(BOOL)animated
CGRect frame = self.longDescField.frame;
frame.size.height = self.longDescField.contentSize.height;
self.longDescField.frame = frame;

self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, self.longDescField.contentSize.height + 200);
self.scrollView.scrollEnabled = YES;
[self.scrollView flashScrollIndicators];

Answer Source

I also believe this is an issue with iOS 7, iOS 8 and now iOS 9.

However, I wasn't able to keep the normal scrolling behavior by setting scrollEnabled = NO before the resize, as igz recommended. Instead I switched scrolling on and off after the resize

// Resize text view here

textView.scrollEnabled = NO;
textView.scrollEnabled = YES;

This forced the cut off text to render correctly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download