views:

225

answers:

2

I'm trying to develop an application using UIWebView. The app is loading remote URL's, so in order to make it quick I want it to use the images included in the application bundle. I was wondering if there is a way to do it without forcing the application to manually replace the address of each image to point into local resources?

A: 

I doubt it, unfortunately. Browser security models in general (and this applies to browsers on the desktop as well of course) don't allow file:// scheme URLs to be used in the context of any other scheme (http://) page. If this was allowed, then arbitrary sites you browse to could load local files and possible access private user data, which would be Bad. Local images with the file:// scheme will only work in a page that is itself in the file:// domain.

I'm not sure how to tell you to accomplish this, but perhaps someone else has a clever idea.

quixoto
A: 

You can use this:

http://stackoverflow.com/questions/2598833/stop-images-from-loading-in-uiwebview

...which sounds horrendous, but is actually quite easy to do, and lets you replace requests for the remote URL with a hit to the local URL.

You'll have to convert the URLs manually, of course.

Adam