-3

我一直在玩我的 iPhone,最近我意识到 iPhone 的电子邮件应用程序可以识别电子邮件中的一行是否代表一个地址。有趣的是,这适用于许多地址模式。我试过美国、德国、法国和西班牙。在所有情况下,地址都以蓝色链接突出显示,就像电话号码一样。所以我的问题是这个地址检测背后的算法是什么?

4

2 回答 2

2

检查文档UIDataDetectorTypes_ 你会发现一个检测格式化为地址的字符串。然后,您可以将此检测器类型添加到.UIDataDetectorTypeAddressUITextView

于 2013-04-09T09:39:37.500 回答
1

你可以设置 theObj.dataDetectorTypes = UIDataDetectorTypeAddress;

或者你可以像这样实现

UITextView *theObj;
theObj = [[UITextView alloc] initWithFrame:CGRectMake(65, 10, 225, 65)];
theObj.text = @"sample@mail.com";
theObj.editable = NO;
theObj.dataDetectorTypes = UIDataDetectorTypeAddress;
[myview theObj];
于 2013-04-09T09:45:47.727 回答