23

I have a UITextView whose content I have set in my .xib.

I am trying to get it to recognize a link using these settings:

Settings

Unfortunately the link does not show up when I run in the simulator (it only shows as plain text):

In simulator

How can I get the UITextView to recognize the link and display it properly?

Shaik Riyaz
  • 11,204
  • 7
  • 53
  • 70
carloabelli
  • 4,289
  • 3
  • 43
  • 70

1 Answers1

54

Set your Textview behavior to Selectable ,

enter image description here

And make sure you have enabled User Interaction .

enter image description here

Toseef Khilji
  • 17,192
  • 12
  • 80
  • 121
  • 1
    Thanks, but why does the selectable make the difference? – carloabelli Dec 25 '13 at 04:39
  • 3
    How can I make it not selectable and make link detection work? By not selectable I mean unable to select a piece of the text to copy – Rodrigo Ruiz Jun 07 '16 at 04:11
  • 1
    I realize this is old, but selectable is required because the links you want the textView to manifest would be user selectable. If they can't select the text, they can't select the link. – Mercutio Jul 06 '16 at 01:53
  • 3
    Make sure UITextview is not editable. Its wont work if its editable – Kiran Patel Feb 23 '18 at 00:45
  • How does WhatsApp achieve this? Their only links are selectable and rest of the text is not. Could someone tell how that could be done? – Arjun May 03 '22 at 09:01