Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to render text with clickable hyperlinks where you can control the action for click?
    primarykey
    data
    text
    <p>I'm tryiing to display some text in my app where there might be some URL in the text. I want the URL to be highlighted as hyperlinks and clickable. Furthermore, when it is clicked, I want to supply a callback where I can perform custom action. Of course the URL should be passed back to my callback so I know what to do with it (say open it in an in-app browser etc). </p> <p>This might sound complicated but basically all the IM apps in the appstore (over 30 of them) have this functionality where a user can send an IM containing a URL and the receiving end can click on it and open the page in an in-app browser. </p> <p>How is this done? I just can't figure it out. If you have a solution, please provide <strong>sample code.</strong> Thank you.</p> <hr> <p><strong>BTW:</strong></p> <p>The answer is <strong>NOT A UIWebView</strong> (because it is very slow to render multiple instances of it). </p> <p>The answer is also <strong>NOT A UITextView</strong> because although it is capable of parsing URL it cannot be set a custom callback on clicks. So it just ends up opening safari.</p> <p>The answer is also <strong>NOT A TTStyledTextLabel</strong> because although it is capable of parsing URL and assigning a custom action to it, it needs to be pre-assigned in a URLMap. And obviously in this case we don't know what the URL is before hand. As far as I know you cannot assign ALL url to a custom action.</p> <p><a href="http://img169.yfrog.com/img169/3373/picture1ufx.png" rel="nofollow noreferrer">alt text http://img169.yfrog.com/img169/3373/picture1ufx.png</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload