【发布时间】:2016-09-27 22:39:43
【问题描述】:
我希望用户选择一个相册,然后在 react-native 中显示它的照片。有 CameraRoll,它能够按 groupName 过滤,但我没有找到如何检索这些 groupNames 的方法。有人知道怎么做吗,还是我需要写一个原生插件?
【问题讨论】:
标签: ios react-native photos
我希望用户选择一个相册,然后在 react-native 中显示它的照片。有 CameraRoll,它能够按 groupName 过滤,但我没有找到如何检索这些 groupNames 的方法。有人知道怎么做吗,还是我需要写一个原生插件?
【问题讨论】:
标签: ios react-native photos
好吧,至少你可以选择很多项目和组...
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);
}
)
【讨论】:
使用这个https://github.com/marcshilling/react-native-image-picker,它可以让你从任何相册中选择一张图片。
【讨论】:
简单的答案是MediaLibrary.getAlbumsAsync()
【讨论】: