【问题标题】:Show photos stored in device on a nativescript android app在 nativescript android 应用程序上显示存储在设备中的照片
【发布时间】:2017-04-06 01:07:33
【问题描述】:

我正在使用 nativescript 制作一个 android 应用程序,我使用 couchbase 作为数据库,我需要存储对使用 camera-module 拍摄的照片的引用项目的缩略图,并在 ListView 中显示这些照片。
我搜索了多个关于使用相机模块和使用 ImageSource 类显示图像的教程,当我使用 fromAsset 传递 cameraModule.takePicture 返回的对象时,它们可以工作,但不是当我使用fromFile 传递同一对象(picture.android 属性)中的路径时,因为它似乎只在应用程序文件夹中有效。

cameraModule.takePicture().then((picture) => {

    let myImage = page.getViewById("image-test");
    let source = new imageSource.ImageSource();

    // This works
    source.fromAsset(picture).then(source => {
        myImage.imageSource = source;
    });

    // This doesn't
    source.fromFile(picture.android).then(source => {
        myImage.imageSource = source;
    });

});

存储引用和重新创建 imageSource 的最佳方式是什么?我可以将整个 imageAsset 对象存储在 couchbase 中吗?或者使用该路径创建 imageSource 的正确方法是什么?

【问题讨论】:

    标签: javascript android nativescript


    【解决方案1】:

    好吧,我不知道我做错了什么,它似乎与图片对象中返回的路径一起工作正常。
    我唯一改变的是同步方法 loadFromFile 的异步方法 fromFile,但也许我的错误在某个地方否则。

    【讨论】:

      猜你喜欢
      • 2019-10-15
      • 1970-01-01
      • 1970-01-01
      • 2018-12-20
      • 1970-01-01
      • 1970-01-01
      • 2020-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多