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

问题描述

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

当有人点击 URL 时 - Safari 应该打开该网站.当有人点击电子邮件链接时 - 邮件应该打开并在字段中显示我的地址当有人点击电话号码时 - 电话应用程序应拨打该号码

有没有人做过这个或知道如何处理它?

谢谢,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 fieldWhen 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 检测网站、邮件和电话号码的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 10:00