views:

41

answers:

2

hi..

I am new to iPhone developemnt.

NSString myUrl = @"www.google.com";

I need to know how to create a hyperlink for the above NSString variable.

In the MFMailComposeViewController I need to use like below

[mailViewController setMessageBody:myUrl isHTML:YES];

Please help me out.

Thanks for any help.

+1  A: 
[NSString stringWithFormat:@"<a href=\"%@\">LINK NAME HERE</a>", myURL];

Add this line to your HTML mail.

muffix
Hi..thank u for the reply.when i use like below NSString *html = @"www.google.com";[mailViewController setMessageBody:[NSString stringWithFormat:@"<a href=\"%@\">LINK NAME HERE</a>", html] isHTML:YES]; when running the app, i don get mouse hover on it and it doesnot get clicked..kindly help me up
iPhonegal
myURL almost certainly needs a URL scheme (e.g. `http://`) prepended.
JeremyP
+1  A: 

The easiest way is to make the UILabel into a UIButton, style it (use Custom type to get rid of button look). Then connect to an Action that opens safari.

The action should do this:

NSURL *url = [[[ NSURL alloc ] initWithString: @"http://www.example.com" ] autorelease]; [[UIApplication sharedApplication] openURL:url];

ajay