【问题标题】:QR Scanner react-native crash on second invocationQR Scanner 在第二次调用时反应原生崩溃
【发布时间】: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


    【解决方案1】:
      <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>
        }
      />
    

    【讨论】:

      【解决方案2】:

      以下解决方案适用于相机屏幕和其他屏幕之间的导航:

      在构造函数中:

      this.state = {
        focusedScreen: true
      };
      

      渲染中:

        render() {
      
          const { focusedScreen } = this.state;
      
          if (!focusedScreen){
            return <View />;
          } else 
          {
      
            return (
                <QRCodeScanner ............
            )
        }
      

      【讨论】:

        【解决方案3】:

        我相信您在该 github 页面上遇到了与 this 相同的问题。

        并建议使用该页面提交有关该软件的问题。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-10-17
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-05-21
          • 2018-08-23
          • 1970-01-01
          相关资源
          最近更新 更多