Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
clq1983 opened this issue Apr 20, 2021 · 4 comments
Open

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

clq1983 opened this issue Apr 20, 2021 · 4 comments

Comments

@clq1983
Copy link

clq1983 commented Apr 20, 2021

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

@clq1983
Copy link
Author

clq1983 commented Apr 20, 2021

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

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

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

@karosLi
Copy link
Owner

karosLi commented May 11, 2021

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

@clq1983
Copy link
Author

clq1983 commented May 11, 2021 via email

@wubiao20150321
Copy link

UIDelegate实现下面的逻辑试下

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants