WKWebview 点击电话 href=“tel:xxx”没有效果是为什么?
光阴似箭催人老,日月如移越少年。
在點擊打電話這個按鈕的時候需要在這個-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationPollowicy)navigationAction decisionHandler:(void (^)(WKNavigationPollowicydler))decisionatdlerydler(FallAction );然後在代理方法中- (void)webView:(WKWebView )webView didStartProvisionalNavigation:(WKNavigation )navigation判斷[webView.URL absoluteString])navigation判斷[webView.URL absoluteString]
貼上代碼:
//如果不實作這個代理方法,預設會屏蔽掉打電話等url-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(idity)(WavigationActiongActionHy)navigationAction decisionHandler:(iddation)(Waviid);
decisionHandler(WKNavigationActionPolicyAllow);
}
(void)webView:(WKWebView )webView didStartProvisionalNavigation:(WKNavigation )navigation{
NSString *path=[YKBDateHelper convertNull:[webView.URL absoluteString]]; NSString * newPath = [path lowercaseString];
if ([newPath hasPrefix:@"sms:"] || [newPath hasPrefix:@"tel:"]) {
UIApplication * app = [UIApplication sharedApplication]; if ([app canOpenURL:[NSURL URLWithString:newPath]]) { [app openURL:[NSURL URLWithString:newPath]]; } return;
}}
電話://xxx?
請問,這個問題解決了嗎,我也遇到了同樣的問題
是因為用的中文冒號吧? 類似 <a href="tel:xxx">xxx</a>,是不會有問題的。
<a href="tel:xxx">xxx</a>
試試看這個
<a href="tel: + 1 + 电话号码>电话号码</a>
冒號:用了中文:)
-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
這個方法中 列印一下navigationAction.navigationType 這個的值 如果是0的話要特殊處理
在點擊打電話這個按鈕的時候需要在這個
-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationPollowicy)navigationAction decisionHandler:(void (^)(WKNavigationPollowicydler))decisionatdlerydler(FallAction );
然後在代理方法中- (void)webView:(WKWebView )webView didStartProvisionalNavigation:(WKNavigation
)navigation判斷[webView.URL absoluteString])navigation
判斷[webView.URL absoluteString]
貼上代碼:
//如果不實作這個代理方法,預設會屏蔽掉打電話等url
-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(idity)(WavigationActiongActionHy)navigationAction decisionHandler:(iddation)(Waviid);
}
(void)webView:(WKWebView )webView didStartProvisionalNavigation:(WKNavigation )navigation
{
if ([newPath hasPrefix:@"sms:"] || [newPath hasPrefix:@"tel:"]) {
}
}
電話://xxx?
請問,這個問題解決了嗎,我也遇到了同樣的問題
是因為用的中文冒號吧?
類似
<a href="tel:xxx">xxx</a>
,是不會有問題的。試試看這個
冒號:用了中文:)
-(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
sionHandler這個方法中 列印一下navigationAction.navigationType 這個的值 如果是0的話要特殊處理