Swift - WKWebView 不打开来自网站的链接我

Swift - WKWebView is not opening links from websitesI

我的 WKWebView

中有下一个政策
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void) {
        switch navigationAction.navigationType {
        case .linkActivated:
            decisionHandler(.allow)
            return
        default:
            break
        }
        decisionHandler(.allow)
    }

但是,每次我尝试打开 link,我都会得到:

BackgroundTask] Background Task 7 ("GDTCCTUploader-upload"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this

[Feedback] failed initializing core haptics engine for <_UIFeedbackCoreHapticsEngine: 0x283fc3aa0>: Error Domain=com.apple.CoreHaptics Code=-4810 "(null)"

我的项目没有任何特别之处,只有浏览器,但它不允许我打开喜欢的网站。

为什么会给我这个错误,我该如何解决?

更新

当我在 google 中搜索单词 cuevana 并尝试打开 link,

时会发生这种情况

其他浏览器可以打开该站点,但该站点产生很多错误,如下所示:

Feedback] failed initializing core haptics engine for <_UIFeedbackCoreHapticsHapticsOnlyEngine: 0x282e49570>: Error Domain=com.apple.CoreHaptics Code=-4810 "(null)"

出于某种原因,我不得不实现这个;

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void) {
        
        if navigationAction.navigationType == WKNavigationType.linkActivated {
            let url = navigationAction.request.url!.absoluteString
            
            let shared = UIApplication.shared
            webview.load(url)
            decisionHandler(WKNavigationActionPolicy.allow)
            return
            
        }

        decisionHandler(WKNavigationActionPolicy.allow)
    }