反应本机图像选择器 - 单击默认图像

问题描述

我有 3 张图片,我希望用户点击它们打开图片选择器(单独)

我使用以下图片选择器:

import * as ImagePicker from 'expo-image-picker';

我使用以下代码(文档中的标准)

//im trying to set a default image before the user can click on the image itself
// which should open up the imager picker and then replace this image

const [image,setImage] = useState(require('../../assets/myimage.jpg'));

    const pickImage = async () => {
        let result = await ImagePicker.launchImageLibraryAsync({
            mediaTypes: ImagePicker.MediaTypeOptions.All,allowsEditing: true,aspect: [4,3],quality: 1,});

        console.log(result);

        if (!result.cancelled) {
            setImage(result.uri);
        }
    };

我像这样调用函数:

<ScrollView horizontal={true} showsHorizontalScrollIndicator={false}>
     <TouchableOpacity style={styles.button} onPress={pickImage}>
         {image && <Image source={{ uri: image }} style={styles.image} />}
     </TouchableOpacity>
     <Image style={styles.image} source = {require('../../assets/image1.jpg')} />
     <Image style={styles.image} source = {require('../../assets/image2.jpg')} />
</ScrollView>

我得到以下信息:

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)