How can I make a clickable link in an NSAttributedString?

It’s trivial to make hyperlinks clickable in a UITextView. You just set the “detect links” checkbox on the view in IB, and it detects HTTP links and turns them into hyperlinks.

However, that still means that what the user sees is the “raw” link. RTF files and HTML both allow you to set up a user-readable string with a link “behind” it.

It’s easy to install attributed text into a text view (or a UILabel or UITextField, for that matter.) However, when that attributed text includes a link, it is not clickable.

Is there a way to make user-readable text clickable in a UITextView, UILabel or UITextField?

The markup is different on SO, but here is the general idea. What I want is text like this:

This morph was generated with Face Dancer, Click to view in the app store.

The only thing I can get is this:

This morph was generated with Face Dancer, Click on http://example.com/facedancer to view in the app store.

23 Answers
23

Leave a Comment