如何为NSString变量创建超链接 [英] how to create a hyperlink for the NSString variable

查看:44
本文介绍了如何为NSString变量创建超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iPhone开发人员的新手.

I am new to iPhone developemnt.

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

我需要知道如何为上述NSString变量创建超链接.

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

MFMailComposeViewController 中,我需要像下面这样使用

In the MFMailComposeViewController I need to use like below

[mailViewController setMessageBody:myUrl isHTML:YES];

请帮帮我.

感谢您的帮助.

推荐答案

最简单的方法是将 UILabel 制成 UIButton ,对其进行样式设置(使用自定义类型"摆脱按钮外观).然后连接到打开野生动物园的动作.

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]; 

这篇关于如何为NSString变量创建超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆