使用修改的 flashMode 属性拍照时 React-Native-Camera 错误
React-Native-Camera Error when take photo with modified flashMode attribute
尝试在修改了 flashMode 属性的情况下拍照时出现以下错误:
{ NSLocalizedDescription: 'Error Domain=AVFoundationErrorDomain
Code=-11800 "The operation could not be completed"
UserInfo={NSUnderlyingError=0x170440210 {Error
Domain=NSOSStatusErrorDomain Code=-16800 "(null)"},
NSLocalizedFailureReason=An unknown error occurred (-16800),
NSLocalizedDescription=The operation could not be completed}' } }
2017-09-12 00:08:29.907053-0300 GimenesApp[1936:765074] { [Error:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could
not be completed" UserInfo={NSUnderlyingError=0x170440210 {Error
Domain=NSOSStatusErrorDomain Code=-16800 "(null)"},
NSLocalizedFailureReason=An unknown error occurred (-16800),
NSLocalizedDescription=The operation could not be completed}]
这是我正在使用的代码片段:
<Camera
captureTarget={Camera.constants.CaptureTarget.disk}
ref={(cam) => {
this.camera = cam;
}}
flashMode={this.state.flashMode}>
<Button onPress={this.takePicture.bind(this)} transparent
<Icon name="ios-radio-button-off" />
</Button>
</Camera>
所以,我解决了这个错误,删除了对 setState
的两次调用
这是我的拍照方法:
takePicture() {
const options = {};
this.camera.capture({metadata: options})
.then((data) => {
this.setState({
PHOTO_PATH: data.path,
IS_NOT_PHOTO_TAKE: false
});
})
.catch(err => {
console.error(err)
});
};
之前,我在 takePicture 方法中设置了两次状态。我只是移动了外面的setState,错误消失了。
我不知道为什么,但现在,它正在工作。
如果有人对此错误有任何解释,请与我们分享。
尝试在修改了 flashMode 属性的情况下拍照时出现以下错误:
{ NSLocalizedDescription: 'Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x170440210 {Error Domain=NSOSStatusErrorDomain Code=-16800 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-16800), NSLocalizedDescription=The operation could not be completed}' } } 2017-09-12 00:08:29.907053-0300 GimenesApp[1936:765074] { [Error: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x170440210 {Error Domain=NSOSStatusErrorDomain Code=-16800 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-16800), NSLocalizedDescription=The operation could not be completed}]
这是我正在使用的代码片段:
<Camera
captureTarget={Camera.constants.CaptureTarget.disk}
ref={(cam) => {
this.camera = cam;
}}
flashMode={this.state.flashMode}>
<Button onPress={this.takePicture.bind(this)} transparent
<Icon name="ios-radio-button-off" />
</Button>
</Camera>
所以,我解决了这个错误,删除了对 setState
的两次调用这是我的拍照方法:
takePicture() {
const options = {};
this.camera.capture({metadata: options})
.then((data) => {
this.setState({
PHOTO_PATH: data.path,
IS_NOT_PHOTO_TAKE: false
});
})
.catch(err => {
console.error(err)
});
};
之前,我在 takePicture 方法中设置了两次状态。我只是移动了外面的setState,错误消失了。
我不知道为什么,但现在,它正在工作。
如果有人对此错误有任何解释,请与我们分享。