【问题标题】:Loading images from disk with titanium使用钛从磁盘加载图像
【发布时间】:2012-11-13 19:02:24
【问题描述】:

我的应用中有一些 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 表单设备中显示图像?

【问题讨论】:

    标签: webview titanium appcelerator


    【解决方案1】:

    我完全不明白你是如何做到这一点的。指向计算机上的文件有什么意义?如果你想使用 localhost,设置一个本地 mamp 服务器:http://www.mamp.info,然后使用像 http://localhost/yourimage.png 这样的 url

    【讨论】:

      猜你喜欢
      • 2018-10-23
      • 1970-01-01
      • 2019-05-10
      • 1970-01-01
      • 2022-06-27
      • 2015-07-13
      • 1970-01-01
      • 2014-06-16
      • 2019-03-06
      相关资源
      最近更新 更多