使用UIDataDetectorTypes自己主动检測电话、网址和邮箱

支付宝公布最新版本号9.0。再一次引发一场撕逼大战。微信说支付宝抄袭了它。支付宝说微信一直都在抄袭自己。在我看来。微信和支付宝都抄袭了对方。对于大佬们的抄袭。我们也是司空见惯了。

支付宝这一次更新,真是赚足了眼球。预计这也是支付宝的推广策略。就是要造势。造势有利于品牌推广。传播速度可想而知。似乎一夜之间都在谈论支付宝和微信。

至于支付宝和微信谁能打过谁,我们拭目以待。

上一篇文章UIWebView使用方法具体解释及代码分享里面提到:

webView.dataDetectorTypes = UIDataDetectorTypePhoneNumber;//自己主动检測网页上的电话号码,单击能够拨打

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

UIDataDetectorTypes的枚举值

typedef NS_OPTIONS(NSUInteger, UIDataDetectorTypes) {
    UIDataDetectorTypePhoneNumber   = 1 << 0,          // Phone number detection
    UIDataDetectorTypeLink          = 1 << 1,          // URL detection    
#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    // All types
};

NS_OPTIONS一般用来定义位移相关操作的枚举值。

UIDataDetectorTypeAddress。UIDataDetectorTypeCalendarEvent不在我们考虑的范围了。

UIWebView有dataDetectorTypes属性,UITextView也有dataDetectorTypes属性。我们来UITextView来举例。

创建UITextView

UI
posted @ 2017-07-10 15:46  zhchoutai  阅读(239)  评论(0编辑  收藏  举报