Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - UITextView doesn't draw text?

I have a UITextView on the screen. This UITextView is covered by a UIView.

When I set the text for this UITextView, if the textView is not visible (UIView is covering it), it doesn't draw the text.

So when I remove the view that is covering my textView there is no text in my textView. If I try scrolling the textview the text will appear suddenly.

any way to force the UITextView to draw the text at all times? (This only happens when I have too much text in it (about 1000 characters))

I tried calling [textView setNeedsDisplay], before and after setting 'text' and it didn't fix the problem

like image 706
aryaxt Avatar asked Apr 01 '26 23:04

aryaxt


2 Answers

I have the same problem, my UITextView does not draw text until I try scrolling it or its parent. [textView setNeedsDisplay] does not work for me. Finally, I increase textView 1px and the problem's gone.

CGRect frame = textView.frame;
frame.size.height += 1;
textView.frame = frame;

I know this method is ugly but it does work.

like image 108
Tùng Đỗ Avatar answered Apr 04 '26 13:04

Tùng Đỗ


Most things in the system will not display when hidden, which would be a waste of resources.

The correct approach is to call setNeedsDisplay: on the UITextView AFTER it has been un-hidden, then it should draw immediatley.

like image 22
Kendall Helmstetter Gelner Avatar answered Apr 04 '26 14:04

Kendall Helmstetter Gelner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!