iOS WKWebView属性

1、WKWebView代理方法

// 页面开始加载时调用
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation;
// 当内容开始返回时调用
- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation;
// 页面加载完成之后调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation;
// 页面加载失败时调用 当开始加载数据时发生错误时调用。
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error;
// 在提交导航期间发生错误时调用。
- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error;

2、WKWebView 拨打电话

- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {
NSString *path = [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;
}
}
特别声明:文章多为网络转载,资源使用一般不提供任何帮助,特殊资源除外,如有侵权请联系!
技术狗 » iOS WKWebView属性