Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-31-2010, 10:47 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 60
racharambola5 is on a distinguished road
Default Text as Hyperlink in iphone

Hi,
I have a text label with the text set as Contact Us.. When user taps on this label it should launch safari to open the web page.My doubt is how to make Contact Us as hyperlink.Please help me guys..I am in final stages of my project..If possible please help me with sample code..thanks for all your time
racharambola5 is offline   Reply With Quote
Old 08-31-2010, 11:16 AM   #2 (permalink)
I will be a billionaire.
 
IphoneSdk's Avatar
 
Join Date: Sep 2009
Location: Scarborough, United Kingdom
Age: 17
Posts: 1,344
IphoneSdk is on a distinguished road
Default

Why don't you just create a button and make it custom so there is no background or outline and then do this code:

Code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];
__________________
iOS Apps | Website | Twitter | Facebook
IphoneSdk is offline   Reply With Quote
Old 08-31-2010, 11:17 AM   #3 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 60
racharambola5 is on a distinguished road
Default

Thanks buddy..I will give a try..I have a text and part of it should be hyperlink can I give a try with the above approach
racharambola5 is offline   Reply With Quote
Old 08-31-2010, 11:31 AM   #4 (permalink)
I will be a billionaire.
 
IphoneSdk's Avatar
 
Join Date: Sep 2009
Location: Scarborough, United Kingdom
Age: 17
Posts: 1,344
IphoneSdk is on a distinguished road
Default

I made you a really quick project to show you. Here is the link to download the project: demo.zip
__________________
iOS Apps | Website | Twitter | Facebook

Last edited by IphoneSdk; 08-31-2010 at 11:35 AM.
IphoneSdk is offline   Reply With Quote
Old 08-31-2010, 11:38 AM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 139
dudeofswim is on a distinguished road
Default

Quote:
Originally Posted by racharambola5 View Post
Thanks buddy..I will give a try..I have a text and part of it should be hyperlink can I give a try with the above approach
Yes. All you have to do is set the UIbutton to custom in ib and its label to whatever

good luck!
dudeofswim is offline   Reply With Quote
Old 08-31-2010, 12:48 PM   #6 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by racharambola5 View Post
Hi,
I have a text label with the text set as Contact Us.. When user taps on this label it should launch safari to open the web page.My doubt is how to make Contact Us as hyperlink.Please help me guys..I am in final stages of my project..If possible please help me with sample code..thanks for all your time
iOS does not support rich text (RTF) like MacOS does. The only UI object that supports clickable text links directly is UIWebView. That's an awfully heavy-weight solution to your problem however.

The other posters have the right idea. Overlay a button on your text, and have the buttons's action trigger an openURL call to launch Safari.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, objective-c, uitextfield, url

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 356
6 members and 350 guests
dre, freewind, hain, HemiMG, lendo, Newbie123
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:01 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0