iOS UITextView recognize wrong link

274 views Asked by At

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.

2

There are 2 answers

0
Hyesang Yu On BEST ANSWER

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.

4
Santu C On

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.