Flipper
Flipper

Reputation: 1107

iOS UITextView recognize wrong link

I have a textview in my cell. I have NSTimer that every 5 seconds changes a content of a cell. First time everything is ok. For example: This is test text find out on www.example.com. This is ok. But on timer I animate the cell and in my animation I'm changing the text of TwxtView. When this happens this is my text: This is test text find out on www.example.com. As you can see, it recognizes the whole text as url link and this is not good. I was looking for solution but could not find it, what's the catch? My TextView has property Editable set to NO and Scrollable set to NO, link detection is enabled.

Upvotes: 0

Views: 275

Answers (2)

Hyesang Yu
Hyesang Yu

Reputation: 26

I had same problem. Clear link attribute before you set your content string.

Try this:

[self.yourTextView setAttributedText:[NSAttributedString new]];
[self.yourTextView setText:contentString];

Good luck.

Upvotes: 1

Santu C
Santu C

Reputation: 2654

Please make sure you have set self.yourTextView.selectable = YES; programmatically or from XIB.

Then you try below trick which work for me .

    self.yourTextView.scrollEnabled = YES;
    [self.yourTextView setText:contentString]; // Set content in 5 secs here 
    self.yourTextView.scrollEnabled = NO; 

Hope this will help you.

Upvotes: 0

Related Questions