我正在构建一个简单的社交媒体应用程序。用户可以添加状态、位置、来自 youtube 的视频和照片。但是我在使用本机图像选择器上传多个图像时遇到问题。我已阅读文档,但我不知道如何解决问题
这是我的函数代码
onPhotoPress() {
const options = {
quality: 1.0,
maxWidth: 50,
maxHeight: 50,
storageOptions: {
skipBackup: true,
},
};
ImagePicker.launchImageLibrary(options, openPicker(), (response) => {
console.log('Response = ', response);
if (response.didCancel) {
console.log('User cancelled photo picker');
}
else if (response.error) {
console.log('ImagePicker Error: ', response.error);
}
else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
}
else {
const source = { uri: `data:image/jpeg;base64,${response.data}` };
this.setState({
avatarSource: source,
name: response.fileName,
data: response.data,
type: response.type,
path: response.uri,
});
}
});
}
Run Code Online (Sandbox Code Playgroud)
这是我查看图像的代码
{this.state.avatarSource !== null ?
<Image
source={this.state.avatarSource}
style={{
flex: 1,
resizeMode: 'contain',
marginVertical: 12,
}}
/> : <View /> }
Run Code Online (Sandbox Code Playgroud)
所以你能帮我,获取多个图像或给我建议另一个库我应该用来解决我的问题
这个库最初是作为原生 iOS 图像选择器的基本桥梁,我想保持这种状态。因此,此处不支持超出本机 UIImagePickerController 支持的功能。多图像选择、对裁剪工具的更多控制和横向支持是原生 iOS 功能中缺少的东西 - 而不是我的库的问题。如果你需要这些东西, react-native-image-crop-picker 可能是你更好的选择。
正如您在React Native Image Picker README 中所见,您无法使用此模块进行多张图片选择。你最好尝试使用React Native Image Crop Picker来做到这一点。
| 归档时间: |
|
| 查看次数: |
25242 次 |
| 最近记录: |