ran*_*234 6 camera qr-code barcode react-native react-native-camera
我正在使用react-native-camera的条形码扫描仪,目前如果我使用它并且有多个 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'
}
}
Run Code Online (Sandbox Code Playgroud)
版本,如果需要:
"react-native": "0.42.3",
"react-native-camera": "0.6.0",
Run Code Online (Sandbox Code Playgroud)
小智 0
<View style='your style'/ >
在<Camera>
和之间插入怎么样</Camera>
?
View将是一个视口(通过Camera重点关注View标签)
<View style={styles.container}>
<Camera
style={styles.preview}
onBarCodeRead={this.onBarCodeRead}
ref={cam => this.camera = cam}
aspect={Camera.constants.Aspect.fill}>
<View style={'your style'}/>
</Camera>
<Button
style={styles.buttonStyle}
<Text>{this.state.qrcode}</Text>
</Button>
</View>
Run Code Online (Sandbox Code Playgroud)
const styles = { 容器:{ height:300,flex:1 },预览:{ flex:1 },buttonStyle:{ marginTop:20,marginLeft:20,marginRight:20,marginBottom:20,alignSelf:'center' } } ````
归档时间: |
|
查看次数: |
5196 次 |
最近记录: |