【问题标题】:Fetch Image stored in Ti.Filesystem appcelerator获取存储在 Ti.Filesystem appcelerator 中的图像
【发布时间】:2017-02-19 07:49:39
【问题描述】:

我已将图像存储在 Ti.FileSystem (appcelerator) 并成功存储。但我无法将其取回并显示在 ImageView 中

FullFileName="HA_2312751361_0566296329";
var fullFileNameForForm=FullFileName+"_form.png";
var fileForm = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,fullFileNameForForm);
console.log("contents="+fileForm); // It gets the contents of the file

if(fileForm.exists()){
    var contents=fileForm.read();
    var image=Titanium.Filesystem.applicationDataDirectory + Ti.Filesystem.separator + contents.image; 
    //it crashes in above line for contents.image
     $.id_buttonImage.backgroundImage=image; 

}
else{
    console.log('fileNotExists');
}

【问题讨论】:

    标签: javascript titanium appcelerator


    【解决方案1】:

    您可以在检查它是否存在后使用$.id_buttonImage.backgroundImage=fileForm.nativePath;。由于它已经是文件的链接,因此您无需再次创建路径。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-29
      • 2017-12-29
      • 1970-01-01
      • 2020-04-23
      相关资源
      最近更新 更多