2012-07-11 50 views
2

我正在构建一个带有UIWebView的应用程序。UIWebView无法检测电话号码链接

web视图应该加载HTML,包括联系电话:链接:

<a href="tel:123456789">call me</a> 

web视图不会使“叫我”链接点击。

我试图

webView.dataDetectorTypes = UIDataDetectorTypePhoneNumber 

但不起作用。

我看着所有的堆栈溢出Q & A的,并没有找到具体到这个问题的答案。

感谢您的帮助, 努尔

+1

我犯了一个相同的Web视图

web = [[UIWebView alloc] initWithFrame:WEBVIEW_FRAME]; web.dataDetectorTypes = UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber; NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"new" ofType:@"html"] isDirectory:NO]]; web.delegate =self; [self.view addSubview:web]; 

和委托方法

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if ([url.scheme isEqualToString:@"tel"]) { [[UIApplication sharedApplication] openURL:url]; } } 

和我的HTML文件如你所描述的虚拟代码正在工作这里NSString * str = @“call me”; webview.dataDetectorTypes = UIDataDetectorTypePhoneNumber; [webview loadHTMLString:str baseURL:nil]; – Bhupesh 2012-07-11 10:19:39

回答

2

<a href="tel://123456789">call me</a> 

希望工程为您更换

<a href="tel:123456789"> call me </a> 

+0

嗨,它没有工作,谢谢你的尝试。 – nurxyz 2012-07-11 12:02:43

+0

它适用于我。 (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)请求导航类型:(UIWebViewNavigationType)导航类型NSURL * url = request.URL; if([url.scheme isEqualToString:@“tel”]){ [[UIApplication sharedApplication] openURL:url]; } return YES; } – sschunara 2012-07-13 07:43:33

2

下面的代码为我工作

添加

<html> 
    <head> 
    <h1>HTML PAGE</h1> 
    </head> 
    <a href="tel:123456789"> call me </a> 
    </html>