Quantcast
Channel: Xamarin.Mac — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 1429

Load content from app bundle with WKWebView.LoadFileUrl

$
0
0

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?


Viewing all articles
Browse latest Browse all 1429

Trending Articles