使用本机更改相机类型后立即拍照

时间:2018-12-03 17:08:39

标签: javascript react-native react-native-camera

我试图在从后置摄像头改为后置摄像头后立即使用React Native相机拍摄照片。为了给您一个想法,代码看起来像这样:

state = {
    type: Camera.Constants.Type.back
}

takePicture = () => {
    const options = {quality:0.5}
    this.setState({type:Camera.Constants.Type.front}, () => {
        this.camera.takePictureAsync(options).then(data => {
            console.log(data)
        });
    })
};

我想我要拍摄的照片将是带有前置摄像头的照片。但是,我得到的照片始终是带有后置摄像头的照片。我有什么想念的吗?

1 个答案:

答案 0 :(得分:0)

在渲染方法中,您是否将类型作为属性添加?

03-Dec-2018 21:26:23.590 WARNING [main] . *** jdbc.MaxLimit in configuration |apex|rt| is using a value of 10, this setting may not be sized adequately for a production environment ***
03-Dec-2018 21:26:23.590 WARNING [main] . *** jdbc.InitialLimit in configuration |apex|rt| is using a value of 3, this setting may not be sized adequately for a production environment ***
03-Dec-2018 21:26:23.791 INFO [main] . Oracle REST Data Services initialized