0
我使用UITextView
的委托方法textView:shouldInteractWithURL:inRange:interaction:
来捕获URL点击。有什么方法可以确定哪个UIDataDetectorTypes
触发了委托方法?确定哪个UITextView UIDataDetectorType被触发
我对电子邮件,电话号码,地址(地理位置),日期/时间等有不同的自定义方法。现在我可以看到的唯一方法是使用RegEx从使用“猜测” URL(这是非常无用的东西比HTTP/HTTPS URL)和经由
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction {
NSString *rawText = [textView.text substringWithRange:characterRange];
// Do fancy stuff with the data
// Hacky way to test if the url tapped isn't an email/map address
BOOL isURL = [[URL absoluteString] isEqualToString:[textView.text substringWithRange:characterRange]];
// Return no when the URL can be captured and custom methods used. Otherwise return YES.
return NO;
}
编辑拍了拍原始数据:我已经跨越NSDataDetector
偶然发现它可以帮助,但我不知道从哪里开始