I am looking for a way, that does not involve a UITextView
or 3rd party framework, to make multiple tappable links, on a label. A side note, with the string, for the label is, it’s fetched from a server, so we don’t know the links ahead of time.
As an example, lets say there’s a post, and it has two links, each to a random site dynamically fetched from the server. After detecting that they are links, which I can do, how would I make those tappable?
I have scoured StackOverflow, there have been no duplicates or this question, that I can find. If you find something exactly like this question, feel free to mark it as a duplicate. All I’ve seen were people recommending to use a UITextView
, a 3rd party framework, or to use attributed strings, but the links are known at that point, they aren’t dynamically fetched.
2
Answers
As @DonMag pointed out, in the comments of the question - I could in fact use a
UITextView
, and disabling scrolling, which fixed the original reason I was having, that made me turn to do it with aUILabel
.If you would like to do it with a UILabel class then:
if you must to display a link as in a browser then: