React Native 世博会相机黑屏在ios第一次-工程应用程序重启

deikduxw  于 2022-11-17  发布在  React
关注(0)|答案(1)|浏览(246)

在IOS上,第一次有用户之前没有给他们的相机权限时,屏幕显示黑屏。如果用户关闭应用程序并返回,相机工作正常。
在授予权限之前,将显示加载屏幕。
有人能帮忙吗?
[黑屏摄影机][1]

const __startCamera = async () => {
        setCameraState({
            ...cameraState,
            previewVisible: false,
            showConnectionError: false,
            showConfirmPage: false,
            showConfirmSuccess: false,
            capturedImage: undefined,
        });
        const { status } = await Camera.requestCameraPermissionsAsync();
        console.log(status);
        if (status === "granted") {
            console.log("granted", status);
            setCameraState({
                ...cameraState,
                isLoading: false,
            });
        } else {
            Alert.alert(t("camera.cameraPermissionError"));
            setCameraState({
                ...cameraState,
                isLoading: true,
            });
            navigation.navigate("Home");
        }

  [1]: https://i.stack.imgur.com/dl68S.png
vnjpjtjt

vnjpjtjt1#

你必须检查是你的许可grandet和他们渲染相机。

import { Camera } from "expo-camera";
    
    const [permission, requestPermission] = Camera.useCameraPermissions();
    
     return ( 
    {permission?.granted ? (<Camera> </Camera>) : (<Text>Waiting you permsision"</Text>}
     );

相关问题