Commit 7cd1185532cc0b7c862290b7161c79ed631df648

Authored by “张旭”
1 parent ca6ffdeb

h5 不走dealloc的问题

metaCode/Classes/Main/HomePage/Controller/WebController/CNWebView.swift
... ... @@ -97,9 +97,9 @@ class CNWebView:UIView,WKNavigationDelegate, WKScriptMessageHandler{
97 97 }
98 98  
99 99 func webViewRemoveScriptMessageHandler(){
100   - self.cnWebView.configuration.userContentController.add(self, name: "pop")
101   - self.cnWebView.configuration.userContentController.add(self, name: "toShare")
102   - self.cnWebView.configuration.userContentController.add(self, name: "openAppPayment")
  100 + self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "pop")
  101 + self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "toShare")
  102 + self.cnWebView.configuration.userContentController.removeScriptMessageHandler(forName: "openAppPayment")
103 103 }
104 104 //电商h5的回调
105 105 func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
... ...
metaCode/Classes/Main/HomePage/Controller/WebController/CNWebViewController.swift
... ... @@ -88,8 +88,8 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{
88 88 }
89 89 }
90 90 }
91   - self.webView.webControllerBackNavBlock = {
92   - self.navigationController?.popViewController(animated: true)
  91 + self.webView.webControllerBackNavBlock = { [weak self] in
  92 + self?.navigationController?.popViewController(animated: true)
93 93 }
94 94 self.webView.webControllerUpdateCurrentUrlBlock = { [weak self] currentUrlStr in
95 95 self!.currentUrl = currentUrlStr
... ... @@ -102,9 +102,9 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{
102 102  
103 103 func h5StopVideoPlayer(){
104 104 // call h5停止播放视频
105   - let data = ["stop": true]
  105 + let data: [String: Any] = ["stop": true]
106 106 self.bridge?.callHandler("wjjStopVideoPlayer", data: data, responseCallback: { responseData in
107   - print("\(responseData ?? "")")
  107 + print("wjjStopVideoPlayer:\(responseData ?? "")")
108 108 })
109 109 }
110 110  
... ...