|
@@ -17,7 +17,7 @@ public class PQBaseWebViewController: PQBaseViewController {
|
|
emptyData.emptyImage = "pic_network"
|
|
emptyData.emptyImage = "pic_network"
|
|
return emptyData
|
|
return emptyData
|
|
}()
|
|
}()
|
|
-
|
|
|
|
|
|
+
|
|
lazy var webView: WKWebView = {
|
|
lazy var webView: WKWebView = {
|
|
let config: WKWebViewConfiguration = WKWebViewConfiguration()
|
|
let config: WKWebViewConfiguration = WKWebViewConfiguration()
|
|
config.allowsInlineMediaPlayback = true
|
|
config.allowsInlineMediaPlayback = true
|
|
@@ -54,7 +54,7 @@ public class PQBaseWebViewController: PQBaseViewController {
|
|
@objc var baseTitle: String?
|
|
@objc var baseTitle: String?
|
|
public var evaluateJavaScript: String? // 交互
|
|
public var evaluateJavaScript: String? // 交互
|
|
var isAddObserve: Bool = false
|
|
var isAddObserve: Bool = false
|
|
- open override func viewDidLoad() {
|
|
|
|
|
|
+ override open func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
super.viewDidLoad()
|
|
// Do any additional setup after loading the view.
|
|
// Do any additional setup after loading the view.
|
|
view.addSubview(webView)
|
|
view.addSubview(webView)
|
|
@@ -62,14 +62,14 @@ public class PQBaseWebViewController: PQBaseViewController {
|
|
navHeadImageView?.backgroundColor = UIColor.white
|
|
navHeadImageView?.backgroundColor = UIColor.white
|
|
}
|
|
}
|
|
|
|
|
|
- public override func viewWillAppear(_ animated: Bool) {
|
|
|
|
|
|
+ override public func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
super.viewWillAppear(animated)
|
|
if (UIApplication.shared.keyWindow?.viewWithTag(cProtocalViewTag)) != nil {
|
|
if (UIApplication.shared.keyWindow?.viewWithTag(cProtocalViewTag)) != nil {
|
|
(UIApplication.shared.keyWindow?.viewWithTag(cProtocalViewTag))?.isHidden = true
|
|
(UIApplication.shared.keyWindow?.viewWithTag(cProtocalViewTag))?.isHidden = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public override func viewWillDisappear(_ animated: Bool) {
|
|
|
|
|
|
+ override public func viewWillDisappear(_ animated: Bool) {
|
|
super.viewWillDisappear(animated)
|
|
super.viewWillDisappear(animated)
|
|
if (UIApplication.shared.keyWindow?.viewWithTag(cProtocalViewTag)) != nil {
|
|
if (UIApplication.shared.keyWindow?.viewWithTag(cProtocalViewTag)) != nil {
|
|
(UIApplication.shared.keyWindow?.viewWithTag(cProtocalViewTag))?.isHidden = false
|
|
(UIApplication.shared.keyWindow?.viewWithTag(cProtocalViewTag))?.isHidden = false
|
|
@@ -100,7 +100,7 @@ extension PQBaseWebViewController: WKNavigationDelegate {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
|
|
|
|
|
|
+ override public func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
|
|
if keyPath == "estimatedProgress" {
|
|
if keyPath == "estimatedProgress" {
|
|
progresslayer.opacity = 1
|
|
progresslayer.opacity = 1
|
|
let float = (change?[NSKeyValueChangeKey.newKey] as! NSNumber).floatValue
|
|
let float = (change?[NSKeyValueChangeKey.newKey] as! NSNumber).floatValue
|
|
@@ -130,7 +130,6 @@ extension PQBaseWebViewController: WKNavigationDelegate {
|
|
webView.evaluateJavaScript(evaluateJavaScript!) { _, _ in
|
|
webView.evaluateJavaScript(evaluateJavaScript!) { _, _ in
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public func webView(_ webView: WKWebView, didFail _: WKNavigation!, withError error: Error) {
|
|
public func webView(_ webView: WKWebView, didFail _: WKNavigation!, withError error: Error) {
|
|
@@ -141,12 +140,9 @@ extension PQBaseWebViewController: WKNavigationDelegate {
|
|
self?.baseTitle = any as? String
|
|
self?.baseTitle = any as? String
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- public func webView(_: WKWebView, didFailProvisionalNavigation _: WKNavigation!, withError _: Error) {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ public func webView(_: WKWebView, didFailProvisionalNavigation _: WKNavigation!, withError _: Error) {}
|
|
|
|
|
|
public func webView(_: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
|
public func webView(_: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
|
BFLog(message: "navigationResponse:\(String(describing: navigationResponse))")
|
|
BFLog(message: "navigationResponse:\(String(describing: navigationResponse))")
|
|
@@ -177,7 +173,7 @@ extension PQBaseWebViewController: WKNavigationDelegate {
|
|
// BFLog(message: "decidePolicyFor \(String(describing: navigationAction))")
|
|
// BFLog(message: "decidePolicyFor \(String(describing: navigationAction))")
|
|
// decisionHandler(.allow)
|
|
// decisionHandler(.allow)
|
|
// }
|
|
// }
|
|
- public override var preferredStatusBarStyle: UIStatusBarStyle {
|
|
|
|
|
|
+ override public var preferredStatusBarStyle: UIStatusBarStyle {
|
|
if #available(iOS 13.0, *) {
|
|
if #available(iOS 13.0, *) {
|
|
return .darkContent
|
|
return .darkContent
|
|
} else {
|
|
} else {
|