- WKWebView中点击按钮调起短信、邮件无反应
UIWebview正常没问题
需要在WKWebView的代理方法中添加一下代码解决问题
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
if ([navigationAction.request.URL.scheme isEqualToString:@"sms"]) {
// 短信
[[UIApplication sharedApplication] openURL:navigationAction.request.URL];
} else if ([navigationAction.request.URL.scheme isEqualToString:@"mailto"]) {
// 邮件
[[UIApplication sharedApplication] openURL:navigationAction.request.URL];
} else {
decisionHandler(WKNavigationActionPolicyAllow);
return;
}
decisionHandler(WKNavigationActionPolicyCancel);
}
网友评论