ios - 升级到 Expo 42(从 39)(React Native)后原生相机渲染损坏
问题描述
我正在使用本机相机(iOS/Android)调用如下:
async function takePhoto() {
const photo = await ImagePicker.launchCameraAsync(cameraOptions);
if (photo.cancelled) {
return '';
}
return photo.uri;
}
自从从 Expo 39 升级到 42 后,它就坏了(见截图)
在我看来,它正在以模式打开。我不知道在哪里改变这个。
预期行为:在 iOS 下全屏显示相机作为本机相机
更新:20210730:同时它已作为错误/问题打开: https ://github.com/expo/expo/issues/13614
任何想法,建议 - 特别是在解决方法方面?
非常感谢。
解决方案
我已经完成了从 EXPO SDK 37 到 EXPO SDK 42 的大规模升级。不得不改变很多关于相机、位置和权限的事情。
使用以下内容时我没有遇到这种行为(我看不到您的导入语句或您的包版本,但这是我已经实现的并且没有遇到任何问题)
// Import statements...
import * as ImagePicker from 'expo-image-picker';
import * as FileSystem from 'expo-file-system';
import { Camera } from 'expo-camera';
// Code within Component
const takePicture = async () => {
// You MUST ask for permissions first.
const permissions = {
[Camera]: await Camera.requestPermissionsAsync()
};
// If denied let the user know its required.
if (permissions[Camera].status !== 'granted') {
return Promise.reject(new Error('Camera Permission Required'));
}
// Then let them launch the camera and perform any other task
await ImagePicker.launchCameraAsync({
allowsEditing: false
})
.then(({ uri }) => imageProcesser(uri))
.then(res => onImageAdded(res))
.catch((e) => console.log(e));
};
// These are my concerning package versions
"expo-camera": "^11.2.2"
"expo-file-system": "~11.1.3",
"expo-image-picker": "~10.2.2",
"expo": "^42.0.3"
推荐阅读
- mysql - 从 2 个表中选择并从表 alia 中获取一个文件
- python - 如何在 pytorch 注意模块中为 Query 制作非方形权重矩阵?
- multithreading - 加载 wxGrid 时的线程 - Python
- javascript - 如何隐藏和显示下拉菜单?
- reactjs - 发送 get 请求时处理参数
- python - 向数据框中添加新列,计算某些组中的条目数
- android - 使用共享首选项隐藏按钮单击活动,android studio
- visual-studio-code - 用 (python) 进程 ID 装饰 VSCode (jupyter) 交互式窗口
- java - 在 DDD 中创建值对象的方法 - 哪种解决方案是最好的?
- emeditor - 如何在 emeditor 中一次搜索多个字符串并为其添加书签?