Created
March 10, 2010 11:27
-
-
Save mborromeo/327782 to your computer and use it in GitHub Desktop.
[iPhone SDK] Load html and assets from local file
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