UIWebView doesn't detect phone number links

北慕城南 提交于 2019-12-06 03:36:11

replace

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

with

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

Hope it works for you.

Below code worked for me

Add the web view

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];

and the delegate method

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

and my html file

  <html>
  <head>
  <h1>HTML PAGE</h1>
  </head>
  <a href="tel:123456789"> call me </a>
  </html>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!