From 4075da2ee804c7b2f9d4c85831047de2978e09f4 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 16 Jun 2020 08:07:54 -0500 Subject: [PATCH] Fix removal of tap zones when removing old web views --- iOS/Article/WebViewController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index 5598abfec..d702b0b87 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -300,8 +300,10 @@ extension WebViewController: UIContextMenuInteractionDelegate { extension WebViewController: WKNavigationDelegate { func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { - while view.subviews.count > 1 { - view.subviews.last?.removeFromSuperview() + for (index, view) in view.subviews.enumerated() { + if index != 0, let oldWebView = view as? PreloadedWebView { + oldWebView.removeFromSuperview() + } } }