【问题标题】:React Native: how to get the names of all the albumsReact Native:如何获取所有专辑的名称
【发布时间】:2016-09-27 22:39:43
【问题描述】:

我希望用户选择一个相册,然后在 react-native 中显示它的照片。有 CameraRoll,它能够按 groupName 过滤,但我没有找到如何检索这些 groupNames 的方法。有人知道怎么做吗,还是我需要写一个原生插件?

【问题讨论】:

    标签: ios react-native photos


    【解决方案1】:

    好吧,至少你可以选择很多项目和组...

    import R from 'ramda';
    import { CameraRoll } from 'react-native';
    let groupNames;
    CameraRoll.getPhotos({
        first:20000
    }).then(
        (result) => {
            const groupNamesAr = R.map(
                (item) => {
                    return item.node.group_name;
                }
            )(result.edges)
            groupNames = R.countBy((i)=>i)(groupNamesAr);
        }
    )
    

    【讨论】:

      【解决方案2】:

      使用这个https://github.com/marcshilling/react-native-image-picker,它可以让你从任何相册中选择一张图片。

      【讨论】:

        【解决方案3】:

        我认为目前这是不可能的。请参阅官方存储库中的this 问题。如果您希望实现此功能,可以对 this 功能请求进行投票。

        【讨论】:

          【解决方案4】:

          简单的答案是MediaLibrary.getAlbumsAsync()

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2012-06-22
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多