使用钛从磁盘加载图像

时间:2012-11-13 19:02:24

标签: webview titanium appcelerator

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

所以我得到这样的道路:

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

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

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

pathes是正确的,如果我使用相同的pathes创建一个完美的图像视图。

这里有一些代码:

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表单设备中显示图像?

1 个答案:

答案 0 :(得分:0)

我看不出你是如何让这一切成功的......你指着计算机上的文件是什么意思?如果要使用localhost,请设置本地mamp服务器:http://www.mamp.info,然后使用类似http://localhost/yourimage.png的网址

相关问题