Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextView don't show text

I have a TextView in my xib file.

After I assign text for it, it doesn't show the text till I double click it, and actually change the selection of the text:

Before double click:

enter image description here

After double click:

enter image description here

After changing selection size:

enter image description here

Do you have any idea, how to show text from the beginning?

Thanks

like image 465
Shefy Gur-ary Avatar asked Dec 26 '22 20:12

Shefy Gur-ary


2 Answers

We found the solution. This situation happens, when you try to update the txt before the view is visible.

We override the function viewDidAppear, and did this code:

// To fix the bug of not showing text in textView
        self.txtViewShowDetails.text = nil;
        self.txtViewShowDetails.text = self.mediaItem.mediaDescription;
        [self.txtViewShowDetails setContentOffset:CGPointZero];

If the view is animated, or inside animated controlView, we have to call the viewDidAppear after animation finished.

like image 163
Shefy Gur-ary Avatar answered Jan 11 '23 10:01

Shefy Gur-ary


I had a similar bug, but it happened when I made the text unselectable. Once I made it selectable again(checked in nib), it fixed the text again. While this isn't a solution to this bug (unless making it unselectable also fixes your problem), hopefully it will help others.

like image 23
Daniel Ryan Avatar answered Jan 11 '23 10:01

Daniel Ryan