For the complete documentation index, see llms.txt. This page is also available as Markdown.

iOS WebView (about:blank) 问题

在 iOS WebView 中处理 about:blank 页面时,您可以通过实现 WKUIDelegate 委托,并将其设置为 _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;
}

最后更新于

这有帮助吗?