Posted by: bearc0025 | January 5, 2010

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.

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

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

<img src="image.png"/>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: