Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ilx.mac

macrumors member
Original poster
Mar 10, 2009
63
0
Hi there,

I have a string like: @"www.macrumors.com". And I am placing it in a UILabel. All i want to do is to set a hyperlink for that value in UILable. I am new to this. can some one help me please?

Thanks in advance!:D
 
A UILabel is not an HTML-aware object. I think you will either need to code a response to the touching of the label that performs a URL navigation or you will need to use a UIWebView which is HTML-aware.
 
Thanks for your reply dejo. But, I think I have not explained my problem in brief.

#1. I am displaying a string "www.macrumors.com" in the label.
#2. I have to set a hyperlink to "www.macrumors.com". (this is what i am not aware of)
#3. How can I set the hyperlink to a string which is displayed in a UILabel?


I hope this explains my problem in brief.

Thanks in advance!:):)
 
What does 'set a hyperlink' mean?

UILabels just display text. They have no other interactivity. The also don't display underlines so they don't have a built in way to display text that looks like a hyperlink (at least an underlined one).

A UIButton can be used to display text and to perform an action when the user taps it.
 
Yeah, hyperlinks are for web urls on webpages...nothing to do with a label. What is it you want, do you want a webpage to open when the label is clicked? Where/why is there a we address in the label?
 
Sorry for the confusion caused. I want to have a hyperlink for a string.

In HTML we would do it with a <a> </a> tag.
Here I have a string which has value - www.macrumors.com. All I want to set a hyperlink to that after displaying it in a button/lable/textfield/textview.

i am not aware of how to set the hyperlink. can you guys help me out? Please

Thanks in advance!
 
And then what? You still haven't defined what 'set a hyperlink' means.

We all know what a hyperlink is in html. It displays text in a distinctive way. When the link is clicked in a web browser the web browser does something, usually it opens a new page in the same web browser window.

What does that have to do with button/lable/textfield/textview?

What is it that you want to appear in the interface? What is it that you want to happen?

What will you say if we say 'it's impossible?'
 
What he means is say you have a label and you have some text in it which contains a URL, so he wants that when someone clicks on the URL , the next page should load up a uiwebview with that link.
 
I was asked on Friday if I could add a web address to the about view, or a toolbar button, that opened a URL in Safari. It might be neater, I thought, to add a webview to the app, but this is another conversation.

Anyway, I realised I didn't know how, so I too am asking what the method is here.

I found this, uiwebview-tutorial which I am currently reviewing for myself.

The Thread starter seems to want to do it directly off a text line [Even if the URL is within a paragraph, I think], and probably needs a button, even if you can't see the 'button'.

What are the other possibilities for doing this?
 
Since 3.0 UITextView has the ability to display links and opens mobileSafari if the link is clicked. I haven't tried this but it's the only way, other than using a web view, that I know of to do anything like this.

Understand that UIWebView isn't a web browser. It can display web pages but using it as a general web browser probably will run into various problems. It's not very configurable and has very few callbacks. I guess that its main purpose is to display styled text content in controlled html documents.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.