From 58b8a9adb04ace1dd7941cef48a5aa40935ffe55 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 13 Feb 2020 17:35:34 -0800 Subject: [PATCH] Render article on to be recycled web view and delay new web view showing to 0.3. Issue #1780 --- iOS/Article/WebViewController.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index a01107185..363cc3272 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -406,7 +406,8 @@ private extension WebViewController { coordinator.webViewProvider.dequeueWebView() { webView in let webViewToRecycle = self.webView - + self.renderPage(webViewToRecycle) + // Add the webview webView.translatesAutoresizingMaskIntoConstraints = false self.view.insertSubview(webView, at: 0) @@ -436,8 +437,10 @@ private extension WebViewController { webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.imageWasClicked) webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.imageWasShown) - self.renderPage() - self.recycleWebView(webViewToRecycle) + self.renderPage(webView) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { + self.recycleWebView(webViewToRecycle) + } } @@ -459,7 +462,7 @@ private extension WebViewController { coordinator.webViewProvider.enqueueWebView(webView) } - func renderPage() { + func renderPage(_ webView: WKWebView?) { guard let webView = webView else { return } let style = ArticleStylesManager.shared.currentStyle