0

I am using text view in tableview cell with default feature for identify link number date address location etc.

But For text input googleco.in in not working and displaying as hyperlink.

If i am using another string like "Google.com", "Yahho.com" is working properly in same implementation. Please suggest default implementation of uitextview.

enter image description here enter image description here

BalKrishan Yadav
  • 467
  • 7
  • 21
  • I don't think it would recognize that as a link. It's not a valid URL. You can test this by adding `https://` in front of it and see if it works then. – kevin Jun 07 '18 at 13:52
  • Possible duplicate of [UITextView with hyperlink text](https://stackoverflow.com/questions/39238366/uitextview-with-hyperlink-text) – Jigar Jun 07 '18 at 13:55

1 Answers1

0

You can use the NSAttributedStringKey .link to indicate that that portion of the attributed string is a link.

For example:

let attributedString = NSMutableAttributedString(string: "googleco.in")
attributedString.addAttribute(.link, value: URL(string:"https://googleco.in")!, range: NSMakeRange(0, attributedString.lenght))
Enrique Bermúdez
  • 1,740
  • 2
  • 11
  • 25
  • I m using default link feature of uitextview. Not Using Attributed string. – BalKrishan Yadav Jun 08 '18 at 05:36
  • Probably I didn't fully express my self. I can see that you are using the link data detector and is recognizing well other strings. I believe that the UITextView's match pattern is not recognizing "googleco.in" as a URL, so I you would have to highlight your link manually. – Enrique Bermúdez Jun 08 '18 at 11:23