我想在网络视图中检测视频全屏进入和退出,并在每种情况下执行一些代码,我需要捕获和处理哪些事件,观察者是否能做到这一点,向用户显示某些选项对我来说至关重要并修改接口。
这是我用于网络视图的代码的一部分
请帮助拯救我的日子
func loadWebSite() {
let theConfiguration:WKWebViewConfiguration? = WKWebViewConfiguration()
let thisPref:WKPreferences = WKPreferences()
thisPref.javaScriptCanOpenWindowsAutomatically = true;
thisPref.javaScriptEnabled = true
theConfiguration!.preferences = thisPref;
self.wkWebView = WKWebView(frame: self.getFrame(), configuration: theConfiguration!)
self.wkWebView?.navigationDelegate = self
self.wkWebView?.uiDelegate = self
self.wkWebView?.bridge.printScriptMessageAutomatically = true
self.wkWebView?.addObserver(self, forKeyPath: "loading", options: .new, context: nil)
self.wkWebView?.addObserver(self, forKeyPath: "estimatedProgress", options: .new, context: nil)
self.wkWebView?.addObserver(self, forKeyPath: "VideoExitFullScreen", options: .new, context: nil)
self.wkWebView?.addObserver(self, forKeyPath: "VideoEnterFullScreen", options: .new, context: nil)
}
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: …Run Code Online (Sandbox Code Playgroud)