我正在使用react-native-camera的条形码扫描仪,目前,如果我使用它并且有多个 QR 码紧密重叠,我将相机对准一个,它会读取其上方的代码显示在屏幕上,但在摄像机视图中。但是,如果我要扫描的那个上面没有 QR 码,那么它会扫描正确的那个,所以它似乎总是扫描相机视图中的顶部 QR 码。
这是我的问题:有没有办法将“扫描区域”限制为与显示器上的相机视图相同的大小和区域?
<View style={styles.container}>
<Camera
style={styles.preview}
onBarCodeRead={this.onBarCodeRead}
ref={cam => this.camera = cam}
aspect={Camera.constants.Aspect.fill}>
</Camera>
<Button
style={styles.buttonStyle}
<Text>{this.state.qrcode}</Text>
</Button>
</View>
const styles = {
container: {
height: 300,
flex: 1
},
preview: {
flex: 1
},
buttonStyle: {
marginTop: 20,
marginLeft: 20,
marginRight: 20,
marginBottom: 20,
alignSelf: 'center'
}
}
版本,如果需要:
"react-native": "0.42.3",
"react-native-camera": "0.6.0",