如何在iPhone上从UIWebView的HTML引用本地图像文件? [英] How to refer a local image file from UIWebView's HTML on iPhone?
本文介绍了如何在iPhone上从UIWebView的HTML引用本地图像文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用< img src =
temp.jpg
我的UIWebView HTML中的/>
。
如何引用名为 temp.jpg的本地文件
以节省宝贵的加载时间?
I would like to use <img src="
temp.jpg
" />
in my UIWebView's HTML.
How can I refer to a local file named temp.jpg
to save precious loading time?
当然显而易见的选择是< img src =
。\ temp.jpg
/>
但我不知道我的根在哪里...
Of course the obvious choice would be <img src="
.\temp.jpg
" />
but I have no idea where my root is...
推荐答案
NSURL *url=[[NSBundle mainBundle] bundleURL];
[webView loadHTMLString:string baseURL:url];
这是根应用程序的主要捆绑包。
This let's the root be the app's main bundle.
这篇关于如何在iPhone上从UIWebView的HTML引用本地图像文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文