Load content from app bundle with WKWebView.LoadFileUrl

SorinNistorSorinNistor Sorin NistorROMember

I have a problem similar to this one:
https://forums.xamarin.com/discussion/61891/wkwebview-load-local-content-with-loadfileurl
This is the code:

string localHtmlPath = System.IO.Path.Combine(NSBundle.MainBundle.ResourcePath, "file.html");
if (System.IO.File.Exists(localHtmlPath))
{
    SourceCodeView.LoadFileUrl(new NSUrl("file://" + localHtmlPath), new NSUrl("file://" + localHtmlPath));
}

The file.html has BundleResource build action, File.Exists returns true and still the WKWebView remains empty.
If localHtmlPath is set to a path outside the app bundle (/Users/myuser/file.html for example), the WKWebView loads the html file without problems.
Is there a setting that prevents the WKWebView to load html files from app bundle?

Tagged:

Best Answer

Answers

Sign In or Register to comment.