WKWebView

作者: 木子影 | 来源:发表于2018-04-17 10:58 被阅读1次

1、WKWebView处理新开窗口的请求处理,贴一个实例代码

-(WKWebView*)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{
    NSString *url = [navigationAction.request.URL absoluteString];
    _htmlVCShouldShowToast = NO;



    APPWKWebViewController *htmlVC = [[WKWebView alloc] initWithFrame:self.webView.frame configuration:configuration];
    NSMutableURLRequest *request = navigationAction.request;
    [request setHTTPMethod:@"POST"];
    [_payInfoStr dataUsingEncoding:NSUTF8StringEncoding];
    [request setValue:[_payInfoStr encodingWithString]forHTTPHeaderField:@"mfscabc"];
    //    [request setHTTPBody:[_payInfoStr dataUsingEncoding:NSUTF8StringEncoding]];
    // WKWebView加载请求
    [webView loadRequest:request];
    if(_htmlVCHaveShowToast){
        [APPShowMessage hiddenToastOnWindow];
    }
    //    [self leftBarButtonItemIsClick];
    return htmlVC;
}

相关文章

网友评论

      本文标题:WKWebView

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