Instead of loading the HTML directly with loadHTMLString
, you can have the web view do the work of loading the HTML from the bundled file. That way it should know where the HTML came from to resolve relative links.
Ex:
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]];
[webview loadRequest:[NSURLRequest requestWithURL:url]];
I haven't tested the above, you may need the inDirectory
clause of the pathForResource
method. Good luck!