From a732dcc5ee5030163526d60f41dcaa0b531d49e8 Mon Sep 17 00:00:00 2001 From: Alan Grgic Date: Mon, 26 Nov 2018 19:32:29 -0600 Subject: [PATCH] don't update source property of iOS webview on load if reading local html content (#4468) --- Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs | 3 +++ Xamarin.Forms.Platform.iOS/Renderers/WebViewRenderer.cs | 6 +++++- Xamarin.Forms.Platform.iOS/Renderers/WkWebViewRenderer.cs | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs b/Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs index fd22271..4c22546 100644 --- a/Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs +++ b/Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs @@ -203,6 +203,9 @@ namespace Xamarin.Forms.Platform.MacOS if (Renderer.Control.IsLoading) return; + if (Renderer.Control.MainFrameUrl == $"file://{NSBundle.MainBundle.BundlePath}/") + return; + Renderer._ignoreSourceChanges = true; Renderer.Element?.SetValueFromRenderer(WebView.SourceProperty, new UrlWebViewSource { Url = Renderer.Control.MainFrameUrl }); Renderer._ignoreSourceChanges = false; diff --git a/Xamarin.Forms.Platform.iOS/Renderers/WebViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/WebViewRenderer.cs index aeec934..cec99fe 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/WebViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/WebViewRenderer.cs @@ -220,8 +220,12 @@ namespace Xamarin.Forms.Platform.iOS if (webView.IsLoading) return; - _renderer._ignoreSourceChanges = true; var url = GetCurrentUrl(); + + if (url == $"file://{NSBundle.MainBundle.BundlePath}/") + return; + + _renderer._ignoreSourceChanges = true; WebView.SetValueFromRenderer(WebView.SourceProperty, new UrlWebViewSource { Url = url }); _renderer._ignoreSourceChanges = false; diff --git a/Xamarin.Forms.Platform.iOS/Renderers/WkWebViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/WkWebViewRenderer.cs index 8b882e2..290cf9b 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/WkWebViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/WkWebViewRenderer.cs @@ -218,8 +218,11 @@ namespace Xamarin.Forms.Platform.iOS if (webView.IsLoading) return; - _renderer._ignoreSourceChanges = true; var url = GetCurrentUrl(); + if (url == $"file://{NSBundle.MainBundle.BundlePath}/") + return; + + _renderer._ignoreSourceChanges = true; WebView.SetValueFromRenderer(WebView.SourceProperty, new UrlWebViewSource { Url = url }); _renderer._ignoreSourceChanges = false; -- 2.7.4