WKWebView

作者: 伯牙呀 | 来源:发表于2017-04-25 16:39 被阅读48次

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

    相关文章

      网友评论

          本文标题:WKWebView

          本文链接:https://www.haomeiwen.com/subject/movkwttx.html