dataDetectorTypes电话链接问题 [英] dataDetectorTypes phone link issue
本文介绍了dataDetectorTypes电话链接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是此问题的重新表述
当我设置 myWebView.dataDetectorTypes = UIDataDetectorTypeNone; 电话链接(在href html标签中)时,处理方式如下:
When i set myWebView.dataDetectorTypes = UIDataDetectorTypeNone; phone links (in a href html tag) are handled like this :
如何处理电话
推荐答案
我还是找不到问题的原因但我找到了一个解决方案。
I have not still found the cause of the problem but I found a solution.
不是像这样的锚点写电话链接:emyphonenumber ,我写 allo:myphonenumber 。
Instead of writing phone links in anchors like this tel:myphonenumber, i write allo:myphonenumber.
因此,调用 shouldStartLoadWithRequest 方法。我可以用 NSURLRequest
对象中的 tel:替换 allo:。
Thus, the shouldStartLoadWithRequest method is called. And i can substitute allo: by tel: in my NSURLRequest
object.
编辑,这里是代码:
- (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;
}
这篇关于dataDetectorTypes电话链接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文