I'm building an app with a UIWebView in it.
The webView should load html that includes tel: links:
<a href="tel:123456789">call me</a>
The webView doesn't make the "call me" link to be clickable.
I tried
webView.dataDetectorTypes = UIDataDetectorTypePhoneNumber
But doesn't work.
I looked in all the stackOverflow Q&A's and found no answer specific to this problem.
Thanks for your help, Nur
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>
来源:https://stackoverflow.com/questions/11430058/uiwebview-doesnt-detect-phone-number-links