UIWebView自动侦测电话,邮件,地址问题

是不是碰到过在webview中一些例如“00.12”或者“13-24”这样的数字被识别成电话号码,或者一个“449164078@qq.com”被识别成邮件链接。
手生的同学可能找不到对策,其实webview中是有属性可以控制是否侦探这些连接的,如果你什么都不需要侦探就可以把webview.dataDetectorTypes设置成 UIDataDetectorTypeNone

以下是文档解释

The types of data converted to clickable URLs in the text view.

Declaration
SWIFT
var dataDetectorTypes: UIDataDetectorTypes

OBJECTIVE-C

@property(nonatomic) UIDataDetectorTypes dataDetectorTypes

Discussion

You can use this property to specify the types of data (phone numbers, http links, and so on) that should be automatically converted to clickable URLs in the text view. When clicked, the text view opens the application responsible for handling the URL type and passes it the URL.

Import Statement

import UIKit

Availability
Available in iOS 3.0 and later.


Defines the types of information that can be detected in text-based content.

Declaration

OBJECTIVE-C

enum{

UIDataDetectorTypePhoneNumber = 1 << 0,

UIDataDetectorTypeLink= 1 << 1,

UIDataDetectorTypeAddress= 1 << 2,

UIDataDetectorTypeCalendarEvent= 1 << 3,

UIDataDetectorTypeNone= 0,

UIDataDetectorTypeAll= NSUIntegerMax }; typedef NSUInteger UIDataDetectorTypes;


Constants
  • UIDataDetectorTypePhoneNumber //侦探电话号码

    Detect strings formatted as phone numbers.

    Available in iOS 3.0 and later.
  • UIDataDetectorTypeLink //侦探可能是url的字符串

    Detect strings formatted as URLs. 

    Available in iOS 3.0 and later.

  • UIDataDetectorTypeAddress //侦探地址信息

    Detect strings formatted as addresses. 

    Available in iOS 4.0 and later.
  • UIDataDetectorTypeCalendarEvent //侦探日历时间

    Detect strings formatted as calendar events. 

    Available in iOS 4.0 and later.
  • UIDataDetectorTypeNone //不侦探任何信息

    Do no data detection.

    Available in iOS 3.0 and later.

  • UIDataDetectorTypeAll //侦探全部

    Detect all available types of data.

    Available in iOS 3.0 and later.

Import Statement

Availability

Available in iOS 3.0 and later.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值