React native 仅在Android上反应本机摄像头错误(创建媒体文件时出错)
我正在使用react-native相机()在react-native中拍照。但是当我试着拍照时,我遇到了一个错误。我得到的错误是创建媒体文件时出错 我的代码如下:React native 仅在Android上反应本机摄像头错误(创建媒体文件时出错),react-native,react-native-camera,React Native,React Native Camera,我正在使用react-native相机()在react-native中拍照。但是当我试着拍照时,我遇到了一个错误。我得到的错误是创建媒体文件时出错 我的代码如下: class TakePicture extends Component { takePicture() { this.camera.capture({target: Camera.constants.CaptureTarget.disk}) .then((data) => this
class TakePicture extends Component {
takePicture() {
this.camera.capture({target: Camera.constants.CaptureTarget.disk})
.then((data) => this.props.pictureTaken(data);)
.catch(err => console.error(err));
}
render() {
return (
<View style={styles.container}>
<Camera
ref={(cam) => this.camera = cam;}
style={styles.preview}
aspect={Camera.constants.Aspect.Fill}>
</Camera>
<View style={styles.footer}>
<View style={styles.footerButton}>
<TouchableHighlight onPress={this.takePicture.bind(this)} underlayColor='#ff1c4d'>
<View style={styles.contentFooterButton}>
<Icon
name='ios-camera-outline'
size={25}
style={styles.icon}/>
<Text style={styles.footerButtonText}>Picture</Text>
</View>
</TouchableHighlight>
</View>
</View>
</View>
);
}
}
类TakePicture扩展组件{
拍照{
this.camera.capture({target:camera.constants.CaptureTarget.disk})
.then((数据)=>this.props.pictureTaken(数据);)
.catch(err=>console.error(err));
}
render(){
返回(
this.camera=cam;}
style={style.preview}
aspect={Camera.constants.aspect.Fill}>
图画
);
}
}
我正在使用:
- 节点v6.9.1
- 反应本机:0.41.2
- 安卓模拟器:安卓6.0
takePicture()
时,我得到了这个错误
有什么建议吗?您是否尝试使用不同的方式保存文件?临时还是磁盘?@JohannesFilter是的,我试过了。