【发布时间】:2018-02-21 13:38:11
【问题描述】:
我正在使用来自https://github.com/moaazsidat/react-native-qrcode-scanner 的 react-native-qrcode-scanner,我完美地阅读了代码,但是当我再次返回 qr-scanner 时它崩溃了。 我认为是因为相机仍在后台工作,有办法在结束时关闭它?
【问题讨论】:
标签: javascript android react-native qr-code
我正在使用来自https://github.com/moaazsidat/react-native-qrcode-scanner 的 react-native-qrcode-scanner,我完美地阅读了代码,但是当我再次返回 qr-scanner 时它崩溃了。 我认为是因为相机仍在后台工作,有办法在结束时关闭它?
【问题讨论】:
标签: javascript android react-native qr-code
<QRCodeScanner
onRead={this.onSuccess.bind(this)}// change {this.onSuccess} to {this.onSuccess.bind(this)}
topContent={
<Text style={styles.centerText}>
Go to <Text style={styles.textBold}>wikipedia.org/wiki/QR_code</Text> on your computer and scan the QR code.
</Text>
}
bottomContent={
<TouchableOpacity style={styles.buttonTouchable}>
<Text style={styles.buttonText}>OK. Got it!</Text>
</TouchableOpacity>
}
/>
【讨论】:
以下解决方案适用于相机屏幕和其他屏幕之间的导航:
在构造函数中:
this.state = {
focusedScreen: true
};
渲染中:
render() {
const { focusedScreen } = this.state;
if (!focusedScreen){
return <View />;
} else
{
return (
<QRCodeScanner ............
)
}
【讨论】:
我相信您在该 github 页面上遇到了与 this 相同的问题。
并建议使用该页面提交有关该软件的问题。
【讨论】: