UITextView can not detect link & address in iOS 7

iOSAppDev picture iOSAppDev · Oct 21, 2013 · Viewed 8.1k times · Source

I have iOS application which supports iOS 6 as well as iOS 7. Now I am showing text in UITextView which contains email address & website urls. In iOS 6 , UITextView detects it correctly but in iOS 7 it doesn't detect when view gets loaded. But when I click on any link , email address it starts detecting all the link / urls.

Is this a bug in iOS 7 or I am missing some settings specially for iOS 7 ? Below are the screenshots of app

1) In iOS 6+ when view loaded

enter image description here

2) In iOS 7 when view loaded

enter image description here

3) In iOS 7 when I tap on any link / email address

enter image description here

4) Here is the settings that I am doing in Interface builder for UITextView.

enter image description here

I checked some links which states that , set

textView.text = nil;
textView.text = @"My required info";

But no luck with above code.

Can any body tell me whats going wrong ? Thanks

Answer

Dragos picture Dragos · Nov 3, 2013

This appears to be a bug in iOS 7.0's UITextViews. You should check out NSDataDetector.You can use this to find links, phone numbers and more http://nshipster.com/nsdatadetector/

It appears that the trick is to textView.scrollEnabled = NO. Seems to fix the problem, although if you need scrolling.