I load a local HTML file in a UIWebView like so:
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]];
In my index.html, how do I load a display a local image (added to project through Xcode) with img src=”…”/> ?
Instead of loading with an
NSURLRequest, read the html file into anNSStringand create anNSURLto the directory with image files.Then use UIWebView’s
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURLmethod.So, you’d have something like…