You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用expo-image-picker关闭选择器后自动跳转至默认主屏幕的问题求助

expo-image-picker关闭选择器后自动跳转至默认主屏幕的问题求助

大家好,我现在在Expo项目里用expo-image-picker实现用户上传图片的功能,为了测试和调试,我暂时去掉了上传流程,只专注做图片选择的逻辑,代码如下:

const handleImageUpload = async () => {
  try {
    const result = await ImagePicker.launchImageLibraryAsync({
      mediaTypes: ["images"],
      quality: 1,
      allowsMultipleSelection: true,
      selectionLimit: 3,
      presentationStyle: UIImagePickerPresentationStyle.AUTOMATIC
    });
    console.log(result)
    // 确保屏幕保持聚焦
    if (result.canceled) {
      console.log('Image selection cancelled');
      return;
    }
  } catch (error) {
    console.error('Error during image selection:', error);
  }
}

对应的触发按钮代码是:

<TouchableOpacity style={styles.uploadButton} onPress={handleImageUpload} >
  <Ionicons name={"add"} size={24} color="white" />
</TouchableOpacity>

但现在遇到个头疼的问题:不管我是没选图片直接关闭选择器弹窗,还是选完图关闭,都会自动跳回应用的主屏幕。我是用安卓自定义开发客户端测试的,有没有哪位朋友遇到过同样的情况?麻烦给我支支招,谢谢大家!

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.07 11:08:03