如何使UITextView检测网站,邮件和电话号码的链接 [英] How to make UITextView detect links for website, mail and phone number

查看:159
本文介绍了如何使UITextView检测网站,邮件和电话号码的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITextView对象。 UIView中的文字有一个电话号码,邮件链接,一个网站链接。我想将它们显示为具有以下功能的链接。



当有人点击URL - Safari应该打开网站。
当有人点击电子邮件链接 - 邮件应该打开我的地址到
当某人敲打电话号码 - 电话应用程序应该拨打电话号码



有没有人这样做过,或者知道如何处理它?<​​/ p>

谢谢,
AJ

解决方案

如果您使用OS3.0



,您可以像以下

  textview.editable = NO; 
textview.dataDetectorTypes = UIDataDetectorTypeAll;


I have a UITextView object. The text in UIView has a phone number, mail link, a website link. I want to show them as links with following functionality.

When someone taps on URL - Safari should open the the website. When someone taps on email link - Mail should open up with my address in to field When someone taps on phone number - Phone application should call the number

Has anyone done this before or knows how to handle it?

Thanks, AJ

解决方案

If you are using OS3.0

you can do it like the following

textview.editable = NO;
textview.dataDetectorTypes = UIDataDetectorTypeAll;

这篇关于如何使UITextView检测网站,邮件和电话号码的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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