Forked from mborromeo/load-html-and-assets-from-local-path
Created
May 24, 2011 06:47
-
-
Save eiffelqiu/988227 to your computer and use it in GitHub Desktop.
Load assets in webview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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