【问题标题】:Native camera rendering broken after upgrade to Expo 42(from 39) (React Native)升级到 Expo 42(从 39)(React Native)后原生相机渲染损坏
【发布时间】:2021-07-18 15:14:24
【问题描述】:

我正在使用本机相机(iOS/Android)调用如下:

  async function takePhoto() {
    const photo = await ImagePicker.launchCameraAsync(cameraOptions);
    if (photo.cancelled) {
      return '';
    }
    return photo.uri;
  }

自从从 Expo 39 升级到 42 后,它就坏了(见截图)

Portrait Landscape

在我看来,它正在以模态方式打开。我不知道在哪里改变这个。

预期行为: iOS下相机全屏显示为原生相机

更新:20210730:同时它已作为错误/问题打开: https://github.com/expo/expo/issues/13614

有什么想法、建议——尤其是在解决方法方面?

非常感谢。

【问题讨论】:

    标签: ios react-native expo


    【解决方案1】:

    我已经完成了从 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"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-21
      • 2019-10-10
      • 2018-02-12
      • 2020-04-16
      • 1970-01-01
      • 1970-01-01
      • 2021-11-18
      • 2018-07-21
      相关资源
      最近更新 更多