这是对this question的重新表述
当我设置myWebView.dataDetectorTypes =UIDataDetectorTypeNone时,电话链接(在html标记中)的处理方式如下:

如何使用shouldStartLoadWithRequest委托方法处理电话链接?
发布于 2010-01-18 11:05:32
我还没有找到问题的原因,但我找到了解决办法。
我写的不是像这个电话号码这样的锚中的电话链接,而是写allo:myphonenumber。
因此,调用shouldStartLoadWithRequest方法。我可以在我的NSURLRequest对象中替换allo: by tel:。
编辑,这是代码:
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType; {
NSURL *requestURL = [[ request URL] retain];
// Check to see what protocol/scheme the requested URL is.
if (
// ( [ [ requestURL scheme ] isEqualToString: @"http" ] || [ [ requestURL scheme ] isEqualToString: @"https" ] ) &&
( navigationType == UIWebViewNavigationTypeLinkClicked )
) {
// Stats
[self recordTouch: [self tagToZone:[[webView superview] tag]]];
// Substitution allo -> tel
NSURL *newURL = [[NSURL alloc] initWithString: [[[request URL] absoluteString] stringByReplacingOccurrencesOfString: @"allo:" withString: @"tel:"]];
[requestURL release];
//return YES;
// Launch
return ![ [ UIApplication sharedApplication ] openURL: [newURL autorelease]];
}
// Auto release
[requestURL release];
return YES;
}https://stackoverflow.com/questions/1984883
复制相似问题