Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextView can not detect link & address in iOS 7

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

like image 535
iOSAppDev Avatar asked Oct 21 '13 07:10

iOSAppDev


2 Answers

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.

like image 177
Dragos Avatar answered Oct 14 '22 00:10

Dragos


It appears that on 7.1 links are detected when Selectable but not Editable.

(IB reports Unsupported Configuration: Data Detection and Editable attributes are mutually exclusive)

like image 9
SwiftArchitect Avatar answered Oct 14 '22 02:10

SwiftArchitect