Reputation: 450
I'm trying to make a custom web page and put it in a webview in Xamarin using C# What I have is a UIViewController containing a UIWebView. In my project I have a folder like this:
But when I try to load the index.html file into the webview nothing happens. I tried just loading an external webpage and it works fine.
this is my code for loading the content in the ViewDidLoad method of the UIViewController:
string fileName = "Content/index.html";
string localHtmlUrl = Path.Combine(NSBundle.MainBundle.BundlePath, fileName);
MyWebView.LoadRequest(new NSUrlRequest(new NSUrl(localHtmlUrl, false)));
MyWebView.ScalesPageToFit = true;
I think it has something to do with the page not finishing it's loading, but I can't figure out how to do this properly.
Upvotes: 0
Views: 1327
Reputation: 450
Derp, always make sure to set the 'Build Action' on your file to BundleResource on each file to include them in the build by right clicking on them...
Upvotes: 2