Load local Html file doesn't refer the js file in UIWebView
Posted
by
Hero Vs Zero
on Stack Overflow
See other posts from Stack Overflow
or by Hero Vs Zero
Published on 2012-07-04T11:57:15Z
Indexed on
2012/07/04
21:16 UTC
Read the original article
Hit count: 203
I am working with UIWebView
project and I want to load an HTML file from a project resource. It is working fine when I run from the URL, but when I view the HTML file locally, JS files are not loaded. Loading the local HTML local file doesn't refer to js files in UIWebView
.
Here's my code to load the HTML file project local resource and does't refer the js file:
NSString *path = [[NSBundle mainBundle] pathForResource:@"textfile" ofType:@"txt"];
NSError *error = nil;
NSString *string = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
NSString *path1 = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path1];
NSLog(@"%@ >>> %@",baseURL,path);
[webview loadHTMLString:string baseURL:baseURL];
This code doesn't find JS files in UIWebView
, even though it loads image files from the project resource successfully.
© Stack Overflow or respective owner