Skip to content Skip to sidebar Skip to footer

How To Use An Iphone Webview With An External Html That References Local Images?

Hi i have an external html on my webserver, that is requested by my iphone app through a webview... in order to make the page load faster, i want to change my html to request stati

Solution 1:

You can set the baseURL for UIWebView to the resource path of your main bundle:

NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];

[webView loadHTMLString:htmlString baseURL:baseURL];

Then you can simply refer to your images like this:

<html><body><imgsrc="test.png" /></body></html>

Post a Comment for "How To Use An Iphone Webview With An External Html That References Local Images?"