问题
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
2) In iOS 7 when view loaded
3) In iOS 7 when I tap on any link / email address
4) Here is the settings that I am doing in Interface builder for UITextView.
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
回答1:
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.
回答2:
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)
回答3:
try just to retype "xyz@gmail.com" or different address. I had the same issues and had to retype email addresses instead of copy/pasting them.
来源:https://stackoverflow.com/questions/19488143/uitextview-can-not-detect-link-address-in-ios-7