开发者

UIWebView Referencing Images/CSS from Documents to Resources

I know there are lots of other UIWebView local file related questions but I can't seem to find an answer to mine.

I'm downloading an HTML document and a CSS document and both get saved in the Documents directory. I need to be able to load images from the Resources directory and the CSS from the Documents directory.

So I've got different paths to deal with. Maybe there is a standard path to get to the Resources folder and the开发者_如何学编程n I can BaseURL to the Documents so I can get to the CSS?

Before anyone asks the reason is that I'm shipping lots of images bundled with the app but I know I will need to add additional one's as they become available and until I can get a new release out and approved I'd like to be able to reference images in the bundle and some externally (external website).


The app bundle is roughly [[NSBundle mainBundle] bundlePath].

The documents directory is roughly [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0].

If you mean you want relative URLs to work between them, the easiest way is probably to copy them to the same directory. I'm also pretty sure that you can embed a default Documents directory by sticking it alongside your .app in the zip; that way you can keep it all in Documents. (I haven't actually tested this though!)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜