6

Possible Duplicate:
How to make an expression clickable on iOS?

On Twitter and Facebook, usernames like @ and hashtags like # are clickable, and do something native within the app.

What is the best way to implement something like this? It would be nice if there was a drop in replacement for a UILabel for example.

Community
  • 1
  • 1
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
  • See here http://stackoverflow.com/questions/5772791/nsattributedstring-and-links-on-ios – Joe Jun 21 '11 at 17:47

2 Answers2

6

The TTTAttributedLabel project on github is a drop-in replacement for UILabel that supports embedding links. https://github.com/mattt/TTTAttributedLabel

runmad
  • 14,846
  • 9
  • 99
  • 140
smountcastle
  • 620
  • 5
  • 14
  • This looks interesting. Would I be able to do my own handling when a link is clicked? For example, present a modal view controller? – Sheehan Alam Jun 21 '11 at 19:06
  • I believe you'll have to write and register your own URL handler so that your application can handle the click. You may wish to also take a look at the Three20 project (https://github.com/facebook/three20/) as all of the view linkage is done via app-internal URLs. – smountcastle Jul 12 '11 at 14:53
-1

I'm not sure what Twitter does, but the Facebook app uses a library called Three20 to achieve Rich Text UILabels. They have the ability to be formatted and have in-line hyperlinks. You should specifically look at TTStyledTextLabel.

Check it out: http://three20.info/

hundreth
  • 841
  • 4
  • 8