Xam.Plugin.Webview
Xam.Plugin.Webview copied to clipboard
iOS - ContentType=StringData, Does not load images,js,css from Resources
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.
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);
}
I've got the same issue and you saved me couple of hour, thanks @j-sauer !
I installed this via NuGet, how do I make this change?
@primehalo You need to download the source, make the modification, and build it yourself...
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.