WKWebView didFinishNavigation不适用于框架/ iframe

时间:2019-10-18 13:29:35

标签: ios webkit wkwebview scorm

我正在尝试使用WKWebView加载其中包含2帧的html。我一次获得了所有主要框架的导航委托,但没有获得子框架的didCommit和didFinish回调。

我的示例html是这样的:

https://example.com <html><head><base href="https://example.com"></head><frameset framespacing="0" rows="*,0" frameborder="0" noresize><frame name="sco" src="https://example.com//assets/s/uruq3acajh9u/x/mobile/path/loading.html"><frame name="adaptor" src="https://example.com//assets/s/uruq3acajh9u/content/mobile/path/1.html?sco_url=https://example.com/content/elearningngx/VHDRczdEy5kO_pRfKsNJEA/1571433806/0088Z2lPcUR4MVljWWlPUVYvSjNrby9OVjJzbk84OENkN1h3SVl3UVBPMG9sb3lXNFFsaHUwT2xDbVhFTzVpMWdiNQ==RnJpIE9jdCAxOCAxMzoyMzoyNiBVVEMgMjAxOQ==/eot/index.html"></frameset></html>

func setupWebView(){  
        if (self.webView != nil){  
            self.webView.removeFromSuperview()  
        }  

        HTTPCookieStorage.shared.cookieAcceptPolicy = .always  

        let userContentController = WKUserContentController()  
        userContentController.addUserScript(HTMLViewScripts.viewportScript)  


        let pref = WKPreferences()  
        pref.javaScriptEnabled = true  
        pref.javaScriptCanOpenWindowsAutomatically = true  
        pref.setValue(true, forKey: "allowFileAccessFromFileURLs")  
        pref.setValue(true, forKey: "_allowUniversalAccessFromFileURLs")  

        let wkWebConfig = WKWebViewConfiguration()  
        wkWebConfig.preferences = pref  
        wkWebConfig.userContentController = userContentController  

        let wkWebSiteStore = WKWebsiteDataStore.nonPersistent()  
        wkWebConfig.websiteDataStore = wkWebSiteStore  

        self.webView = WKWebView(frame: CGRect(x: 0, y: 0, width: Constants.screenSize.width, height: self.playerContainer.frame.size.height), configuration: wkWebConfig)  
        self.webView.navigationDelegate = self  
        self.webView.uiDelegate = self  
        self.playerContainer.addSubview(self.webView)  
    }  

valuateJavaScript也有同样的问题。使用评估JavaScript加载“ about:blank”时,没有得到任何回调。似乎是与框架相关的问题。

任何线索都将被应用。预先感谢。

0 个答案:

没有答案