Shefy Gur-ary
Shefy Gur-ary

Reputation: 658

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

Upvotes: 5

Views: 3876

Answers (4)

Gurjinder Singh
Gurjinder Singh

Reputation: 10329

In my case text was long and it was trimming from end. I was setting text first then font and colour. I Set font first then text. It works for me.

Upvotes: 0

Daniel Ryan
Daniel Ryan

Reputation: 7100

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.

Upvotes: 2

Shefy Gur-ary
Shefy Gur-ary

Reputation: 658

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.

Upvotes: 9

Hemant Dixit
Hemant Dixit

Reputation: 1145

think you have set TextView custom font in IB .so you need to set custom font in code.Please set system font in IB and check in both device

TextView.font=[UIFont fontWithName:@"HelveticaNeue-Medium" size:17.0];

Upvotes: 0

Related Questions