tags:

views:

3402

answers:

6

Hi there,

I have been searching for this for hours but I failed. I probably don't even know what should I be looking for.

Many applications have text and in this text are web hyperlinks in rounded rect, when I click them UIWebView opens. What puzzles me is that they often have custom links, for example if words starts with # it is also clickable and aplication responds by opening another view. How can I do that? Is it possible with UILabel or do I need UITextView or something else?

I really hope it is standard functionality and i don't need to subclass anything :/

+4  A: 

you might want to take a look at Joe Hewitt's open sourced three20 project. He has an example of how to build custom labels that have hyperlinks.

three20 project

zPesk
A: 

UITextView supports data-detectors in OS3.0, whereas UILabel doesn't.

If you enable the data-detectors on the UITextView and your text contains URLs, phone numbers, etc. they will appear as links.

Charles Gamble
yeah, I know about this, but I need also custom detection, e.g. #some_word as mentioned in my question
Lope
A: 

For fully custom links, you'll need to use a UIWebView - you can intercept the calls out, so that you can go to some other part of your app instead when a link is pressed.

Kendall Helmstetter Gelner
+7  A: 

this is exactly what I needed :)

Lope
+2  A: 

The UIButtonTypeCustom is a clickable label if you don't set any images for it.

Iggy
A: 

fancy uilabel has some problem with multiline links. did you notice? did you find any solution to that? I tried to hack it but no success (so far :).

Cesare
Yeah I did notice that, but project that I needed it for got canceled shortly after I started using it, so I didn't have to fix it :)
Lope