使用UIDataDetectorTypes自动检测电话、网址和邮箱


1.webView里如果有电话号码的话,设置这个熟悉可以点击拨打
webView.dataDetectorTypes = UIDataDetectorTypePhoneNumber;//自动检测网页上的电话号码,单击可以拨打

接下来我们来简单讲一下,使用UIDataDetectorTypes自动检测电话、网址和邮箱。我们先来看看UIDataDetectorTypes有哪些枚举值。

UIDataDetectorTypes的枚举值

typedef NS_OPTIONS(NSUInteger, UIDataDetectorTypes) {
    UIDataDetectorTypePhoneNumber   = 1 << 0,          // 检测电话
    UIDataDetectorTypeLink          = 1 << 1,          // 检测邮箱和网址    

#if __IPHONE_4_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED UIDataDetectorTypeAddress = 1 << 2, // Street address detection UIDataDetectorTypeCalendarEvent = 1 << 3, // Event detection #endif UIDataDetectorTypeNone = 0, // No detection at all UIDataDetectorTypeAll = NSUIntegerMax // 检测电话、网址和邮箱 };
2.UIWebView有dataDetectorTypes属性,UITextView也有dataDetectorTypes属性。
具体详细:http://www.superqq.com/blog/2015/07/09
/shi-yong-uidatadetectortypeszi-dong-jian-ce-dian-hua-,-wang-zhi-he-you-xiang
/?hmsr=toutiao.io&utm_medium=toutiao.io&utm_source=toutiao.io

posted @ 2016-02-24 17:49  蓝鹰ios  阅读(454)  评论(0编辑  收藏  举报