簡體   English   中英

QR 掃描儀在第二次調用時反應本機崩潰

[英]QR Scanner react-native crash on second invocation

我使用來自https://github.com/moaazsidat/react-native-qrcode-scanner 的react-native-qrcode-scanner 並且我完美地閱讀了代碼,但是當我再次回到 qr-scanner 時它崩潰了。 我認為這是因為相機仍在后台工作,有沒有辦法在結束時關閉它?

我相信您在該 github 頁面上遇到了與相同的問題。

並建議使用該頁面提交有關該軟件的問題。

以下解決方案適用於相機屏幕和其他屏幕之間的導航:

在構造函數中:

this.state = {
  focusedScreen: true
};

在渲染中:

  render() {

    const { focusedScreen } = this.state;

    if (!focusedScreen){
      return <View />;
    } else 
    {

      return (
          <QRCodeScanner ............
      )
  }
  <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>
    }
  />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM