Reset all the web views when coming back to the foreground incase one of them is unavailable now

This commit is contained in:
Maurice Parker
2020-05-06 14:53:09 -05:00
parent e2267d14ee
commit 5f60b84b8b
2 changed files with 18 additions and 16 deletions

View File

@@ -148,7 +148,8 @@ class WebViewController: UIViewController {
}
func fullReload() {
self.loadWebView()
view.subviews.first?.removeFromSuperview()
loadWebView()
}
func showBars() {
@@ -288,10 +289,10 @@ extension WebViewController: UIContextMenuInteractionDelegate {
// MARK: WKNavigationDelegate
extension WebViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if navigationAction.navigationType == .linkActivated {
guard let url = navigationAction.request.url else {
decisionHandler(.allow)
return
@@ -313,13 +314,13 @@ extension WebViewController: WKNavigationDelegate {
} else {
decisionHandler(.allow)
}
} else {
decisionHandler(.allow)
}
}
func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
fullReload()
}
}