【发布时间】: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