how to load local html file into uiwebview iphone
Posted
by
madcoderz
on Stack Overflow
See other posts from Stack Overflow
or by madcoderz
Published on 2011-08-15T09:08:05Z
Indexed on
2014/06/11
9:25 UTC
Read the original article
Hit count: 144
I'm trying to load a html file into my UIWebView but it won't work. Here's the stage: I have a folder called html_files in my project. Then I created a webView in interface builder and assigned an outlet to it in the viewController. This is the code I'm using to append the html file:
-(void)viewDidLoad
{
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"html" inDirectory:@"html_files"];
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
[webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@""]];
[super viewDidLoad];
}
That won't work and the UIWebView is blank. I'd appreciate some help.
© Stack Overflow or respective owner