在 iOS 4之后。苹果废弃了 webView.detectsPhoneNumbers = YES; 这个方法来检测电话 号码。
//自动检测网页上的电话号码,单击可以拨打。(该方法被弃用)
// webView.detectsPhoneNumbers = YES;
更换为此方法:其它的还可以检测 邮箱等。
webView.dataDetectorTypes = UIDataDetectorTypePhoneNumber;
API文档上如此
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