Skip to content

Instantly share code, notes, and snippets.

@mborromeo
Created March 10, 2010 11:27
Show Gist options
  • Save mborromeo/327782 to your computer and use it in GitHub Desktop.
Save mborromeo/327782 to your computer and use it in GitHub Desktop.
[iPhone SDK] Load html and assets from local file
// Load html from local file
NSString *imagePath = [[NSBundle mainBundle] resourcePath];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"localpage" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
[webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString: [NSString stringWithFormat:@"file:/%@//",imagePath]]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment