Context: iOS App written in Obj-C.
I'm trying to load local HTML files which have local images attached to them.
The HTML files are stored in a directory called pages. The images are stored in a directory called images. Here's the folder structure on the project:
/
-/ Images
-/ Pages
Other files
Both "pages" and "images" directories are listed in my project and under Copy Bundle Resources in the Build Phases of my project. When I right click them there, I can Show them in the Finder and see all the individual .html and .jpg files.
I'm having a couple of issues with my code, the main of which is, even though the html pages are loading, the images - which are linked through img tags - are not.
I have tried
Here's the code that loads the HTML page without the images (I'm almost certain that this particular code used to work in the past):
// Linkpath is the path to the HTML file
NSData *htmlData = [NSData dataWithContentsOfFile:linkPath];
if (htmlData) {
[webWiki loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:linkPath]]];
}
And here's a sample HTML page: http://pastebin.com/b1KTZS6A
Here are some of the solutions I've already tried:
One:
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSString* newStr = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
[webWiki loadHTMLString:newStr baseURL:baseURL];