Forum Xamarin.Forms

css path doesnt work on device, but on simulator

Hi!

We are having a big problem with our iOS app that we built with xamarin forms, the app is caching a html and a css script to the device, which then is being rendered for the user to see.
We are using xlabs hybridwebview. The problem is that while running the app on an iOS device (iPad) the webview only renders the html and does not load the css file, or at least the css is not being rendered. But if we run the app in the simulator the css is being rendered.

This line of code calls a method that returns the path, this path is used to save a folder containing an html file and a css file:
var path = Path.Combine(DependencyService.Get<IFileHelper>().GetDocumentsFolderPath(), form.id.ToString()) + "/";

Note: we have tried without the ending slash but no difference.

This is the method that returns the path to the css file, it works on the simulator but not on the device:

public string GetDocumentsFolderPath() { return Environment.GetFolderPath(Environment.SpecialFolder.Personal); }

This is how we load the hybridwebview
protected override void OnAppearing() { var path = Path.Combine(DependencyService.Get<IFileHelper>().GetDocumentsFolderPath(), form.id.ToString()) + "/"; var html = we read the html from the path as a stream (this works); webview.LoadContent(html, path); }

Answers

Sign In or Register to comment.