UITextViews in a UITableView link detection bug in iOS 7

This appears to be a bug in iOS 7.0's UITextViews. A similar question has a workaround which seems to help: set the text view's text to nil before setting it to the new text string.


Several suggestions here and through links provided did not help me with this bug.

I tried setting attributed text, setting text to nil, setting text to @"".

In the end forcing the text view in an out of editable mode did the trick. In prepare for reuse

- (void)prepareForReuse
{
  ...
    textView.editable = YES;
    textView.editable = NO;
  ...
}

None of these answers worked for me (iOS8, Swift), the only thing that worked for me was to first set the text to nil and then prepend the new text with a non-visibile whitespace unicode character (I chose \u200B, which is the ZERO WIDTH SPACE character but any character works):

textView.text = nil
textView.text = "​\u{200B}\(newText)"

Found a better way to solve this problem. This requires an extra step every single time you set text. But this definitely fixes the problem.

_textView.selectable = NO; // set it to NO clears all possible data detection work so far.
_textView.selectable = YES; // set it to YES so that actual links are detected.

Basically data detection requires the selectable field to be set to YES to work. When you set it to NO, its completely removed.

Note: This is only for ios7.