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 hybridwebviewprotected 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
Hi @CyberChris,
Check this out.. this might help you. Means you have to modify the renderer though: https://gist.github.com/amster/9160860
Also, this might help: http://stackoverflow.com/questions/12592811/images-css-not-loading-in-iphone-uiwebview
The problem is that we are using Xlabs hybridwebview, the hwv does not use NSURL instead it requires a string as baseurl. Can we use the personal special folder for this like we do in our example? It is working flawless in simuator and we can read the html as a stream from that directory.
The URL we are getting from the path is /var/mobile/Containers/Data/Application/6C618D0D-5D4C-992A-6A9FC-4621DAC/Documents/1332