Skip to content

Display a local/bundle image in UIWebView

I have local XML files I’m displaying in a UIWebView but I need to add images into the text to display. The images are local to the app so they’re in the bundle.

[code]
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSURL *bundlePathURL = [NSURL fileURLWithPath:bundlePath];
[super loadHTMLString:contents baseURL:bundlePathURL];
[/code]

Then you can reference the images directly in your HTML like…

[code]
<img src="image.png"/>
[/code]