Specifically, I have a folder structure that looks like the below:
- about (main folder)
- css (this sub-folder contains the css files)
- img (this sub-folder contains the img files)
- js (this sub-folder contains the js files)
- page (this subfolder contains the index.html file)
If I click on the index.html file from a normal computer browser, everything works as expected.
However, I am trying to load this index.html into a UIWebView
.
So far, what I've done is I dragged the "about" folder to XCode and copied it there as I would any other file. Then I tried the following code:
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath]];
[webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL];
The webview loads the index.html, however it doesnt load the images/css/js, as I presume it can't find them within the folder structure.
Any help would be appreciated! Thank you!