0

Hey, I have a webView inside my iPhone app. The webView opens a html page (not on iPhone) on a server. Now the website contains an html image. Since iPhone doesnt cach and is loading slowly i like to link the html image to a local resource in my app.

Does anyone know how to do this? Is that even possible?

Xrth
  • 3
  • 1
  • take a look at this post to help you through some gotchas http://stackoverflow.com/questions/478665/link-to-resources-inside-webview-iphone – Aaron Saunders Nov 18 '10 at 18:27

2 Answers2

0

You could try it is a "file://item.png" in your HTML. The images would have to go in your bundle - I think.

Try looking at this post:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/1784-how-can-i-access-local-html-file-using-uiwebview.html

Brad
  • 11,262
  • 8
  • 55
  • 74
0
NSString *localPng = [[NSBundle mainBundle] pathForResource:@"item"
                                                       ofType:@"png"];
NSData *htmlData = [NSData dataWithContentsOfFile:localPng];
[webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8"
                                             baseURL:[NSURL URLWithString:@""]]; 
Aaron Saunders
  • 33,180
  • 5
  • 60
  • 80