Load local Html file doesn't refer the js file in UIWebView
- by Hero Vs Zero
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.