Xam.Plugin.Webview icon indicating copy to clipboard operation
Xam.Plugin.Webview copied to clipboard

iOS - ContentType=StringData, Does not load images,js,css from Resources

Open j-sauer opened this issue 7 years ago • 5 comments

Hi,

under iOS the webview does not load images from the bundle resources that are referenced in the string data. E.g.

<img src="icon100100.png"/> does not show the image although it is part of the bundle resources.

j-sauer avatar Feb 05 '18 17:02 j-sauer

Adding a slash to the end of the base url seems to fix it.

void LoadStringData()
        {
            if (Control == null || Element == null) return;

            var nsBaseUri = new NSUrl($"file://{Element.BaseUrl ?? BaseUrl}/");
            Control.LoadHtmlString(Element.Source, nsBaseUri);
        }

j-sauer avatar Feb 06 '18 18:02 j-sauer

I've got the same issue and you saved me couple of hour, thanks @j-sauer !

Nico04 avatar Jun 16 '18 15:06 Nico04

I installed this via NuGet, how do I make this change?

primehalo avatar Jul 04 '18 08:07 primehalo

@primehalo You need to download the source, make the modification, and build it yourself...

Nico04 avatar Jul 05 '18 08:07 Nico04

You can add the slash after Initialize:

Xam.Plugin.WebView.iOS.FormsWebViewRenderer.Initialize(); Xam.Plugin.WebView.iOS.FormsWebViewRenderer.BaseUrl += "/"; // Workaround for Bug

This works with NuGet package.

mdonat avatar Apr 05 '19 12:04 mdonat