How do I display a local html file in a UIWebView?

Posted by Thomas on Stack Overflow See other posts from Stack Overflow or by Thomas
Published on 2010-03-15T21:28:17Z Indexed on 2010/03/15 21:29 UTC
Read the original article Hit count: 428

I have a relatively simple question that I cannot seem to find the answer for. While doing the Google Maps Java API Tutorials, I ran into a problem. I can load an HTML file from the web, but when I try it locally, it just displays the contents of the file instead of running the script.

Here's what works:

NSString *url = @"http://code.google.com/apis/maps/documentation/v3/examples/geocoding-simple.html";
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
[webView loadRequest:request];

I want to store the HTML file locally and run it from the device itself, so I tried:

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"geocoding-simple" ofType:@"html"]isDirectory:NO]]]; 

and it just displayed the contents of the file.

What am I doing wrong here?

Thomas

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about uiwebview