Remove flash when changing out the web view upon returning to the foreground
This commit is contained in:
parent
8fc915f5dc
commit
211e44fff5
|
@ -148,8 +148,7 @@ class WebViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
func fullReload() {
|
func fullReload() {
|
||||||
view.subviews.first?.removeFromSuperview()
|
loadWebView(replaceExistingWebView: true)
|
||||||
loadWebView()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func showBars() {
|
func showBars() {
|
||||||
|
@ -290,6 +289,12 @@ extension WebViewController: UIContextMenuInteractionDelegate {
|
||||||
|
|
||||||
extension WebViewController: WKNavigationDelegate {
|
extension WebViewController: WKNavigationDelegate {
|
||||||
|
|
||||||
|
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||||
|
if view.subviews.count > 1 {
|
||||||
|
view.subviews.last?.removeFromSuperview()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||||
|
|
||||||
if navigationAction.navigationType == .linkActivated {
|
if navigationAction.navigationType == .linkActivated {
|
||||||
|
@ -403,10 +408,10 @@ private struct ImageClickMessage: Codable {
|
||||||
|
|
||||||
private extension WebViewController {
|
private extension WebViewController {
|
||||||
|
|
||||||
func loadWebView() {
|
func loadWebView(replaceExistingWebView: Bool = false) {
|
||||||
guard isViewLoaded else { return }
|
guard isViewLoaded else { return }
|
||||||
|
|
||||||
if let webView = webView {
|
if !replaceExistingWebView, let webView = webView {
|
||||||
self.renderPage(webView)
|
self.renderPage(webView)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue