karosLi/KKJSBridge

如何实现重定向页面的跳转

clq1983 opened this issue · 4 comments

我发现如果有302跳转,就会跳转不过去,页面卡死,我实现下面的方法也没有效果:

实现如下方法,还是没有效果,请问楼主这个问题有什么好的方法解决不?

  • (void)URLSession:(NSURLSession *)session
    task:(NSURLSessionTask *)task
    willPerformHTTPRedirection:(NSHTTPURLResponse *)response
    newRequest:(NSURLRequest *)request
    completionHandler:(void (^)(NSURLRequest *))completionHandler
    {
    NSURLRequest *redirectRequest = request;

    if (completionHandler) {
    completionHandler(redirectRequest);
    }
    }

如果取消webview复用会有问题吗?

UIDelegate实现下面的逻辑试下

  • (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures {
    if (!navigationAction.targetFrame.isMainFrame) {
    [webView loadRequest:navigationAction.request];
    }
    return nil;
    }