Nativescript:如何从画廊获取所有图像?

时间:2018-01-31 17:09:26

标签: javascript android ios typescript

是否有机会访问图库,获取照片列表并在应用程序中使用它们?当然,如果可以按标准过滤它们(按日期范围拍照)?

1 个答案:

答案 0 :(得分:0)

GingerComa,我想你想用户从画廊中选择图片吧?我用这个nativescript插件完成了这个:

https://www.npmjs.com/package/nativescript-imagepicker

import * as imagepicker from "nativescript-imagepicker";

let context = imagepicker.create({
    mode: "single" // use "multiple" for multiple selection
});

context
    .authorize()
    .then(function() {
        return context.present();
    })
    .then(function(selection) {
        selection.forEach(function(selected) {
            // process the selected image
        });
        list.items = selection;
    }).catch(function (e) {
        // process error
    });