我正在使用 React Native 和 expo,expo-image-picker 在 iO 上运行得很好,在 Android 上也运行得很好,但有一个例外。当用户从图库中提取图片时,没有“确定”或“选择”或“完成”按钮。
用户必须单击裁剪按钮才能接受图像。这是典型的吗?我觉得这会令人困惑并且用户体验很差......
const chooseImage = async (useCamera, index) => {
if (!(await checkPermission(useCamera))) {
Alert.alert(
"Permission missing.",
"Camera permission is required to take image."
);
return;
}
const method = useCamera ? "launchCameraAsync" : "launchImageLibraryAsync";
const result = await ImagePicker[method]({
allowsEditing: true,
base64: false,
aspect: [3, 4],
});
if (!result.cancelled) {
// upload image and retrieve image url
const {height, width, type, uri} = result;
profile.images[index] = uri;
if (uri != null) {
setProfile(profile);
}
setChangedValue("images");
}
};
更新 发现如果我删除编辑功能我可以选择照片
allowsEditing
。但我希望用户能够进行编辑,所以我很好奇为什么编辑上没有“确定”按钮?
我发现裁剪按钮是“完成”按钮。
没有其他方法可以实现图像的选择,所以这只是图像选择器的设计方面。
如果您需要选择图像而不进行编辑,只需将“allowsEditing”设置为 false 即可。它将跳过编辑/裁剪步骤。