0

我的应用程序中有一些 webviews,webviews 从服务器加载图像,我解析了所有路径并兑现了图像。

所以我得到这样的路径:

file://localhost/Users/Fincha/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/1DC70FE8-0FEA-46AD-9A49-18E78282C2CA/Documents/files/4c06c87edbc3994829483e7b6be1d89c.png

在我的 iphone 模拟器中,在 iphone 上类似。

我尝试替换我的 webview 中的路径以使应用程序从磁盘加载图像,并且它成功但我看不到图像甚至 js 或样式表(它们也被缓存)。图像标签呈现为空。

路径是正确的,如果我创建一个具有相同路径的图像视图,它可以完美地工作。

这里有一些代码:

var webView = Ti.UI.createWebView({
            // url : urlToShow,
            // image : "file://localhost/Users/Fincha/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/1DC70FE8-0FEA-46AD-9A49-18E78282C2CA/Documents/files/4c06c87edbc3994829483e7b6be1d89c.png",
            html : "<img height='200' width='300' src='file://localhost/Users/Fincha/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/1DC70FE8-0FEA-46AD-9A49-18E78282C2CA/Documents/files/4c06c87edbc3994829483e7b6be1d89c.png' />", // replacePathesInHTML(data.data[elDiD].content),
            height : Titanium.UI.SIZE
        });

那么如何在 webview 表单设备中显示图像?

4

1 回答 1

0

我根本不明白你是如何让这个成功的。指向计算机上的文件有什么意义?如果要使用 localhost,请设置本地 mamp 服务器: http: //www.mamp.info,然后使用类似的 urlhttp://localhost/yourimage.png

于 2012-11-16T00:37:14.120 回答