【问题标题】:PhoneGap QR Code Scanner by XZingZXing的PhoneGap QR码扫描仪
【发布时间】:2013-01-25 01:51:31
【问题描述】:

我正在尝试让 XZing 在我的 PhoneGap Iphone 应用程序上运行:

在做了一些研究后,我找到了这个链接,以获得将 XZing 安装到我的应用程序的最佳说明:

Why can't XCode 4 find my .h files during a build?

我完成了这些步骤并运行了应用程序,没有出现任何错误。

现在我正在尝试运行扫描仪并使用 BarcodeScanner 测试文件,这是我的代码

<!DOCTYPE html>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title>Hello World</title>
    </head>
    <body onLoad="onLoad()">
        <div class="app">
            <div id="running-bits">

<button id="scan-button">scan: ?</button>

<p>(<span id="test-count-current">?</span>
/
<span id="test-count-total">?</span>)

<p><img id="image" src="">

<p>expected text:
<br><tt><span id="test-text">?</span></tt>

</div>

<p><b id="test-done"></b>
<br><button id="start-over">start over</button>

<p>Results:
<ul id="results-list">
</ul>
        </div>
        <script type="text/javascript" src="cordova-2.3.0.js"></script>
        <script src="js/barcodescanner.js"></script>
        <script src="js/phonegap-app.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript">
            app.initialize();
        </script>
    </body>
</html>

phonegap-app.js 的代码在下面的链接中:

https://github.com/phonegap/phonegap-plugins/blob/master/iPhone/BarcodeScanner/test/phonegap-app/phonegap-app.js

但是,当我单击扫描仪的扫描按钮时,它会失败,并且我在日志中收到此错误:

BarcodeScanner 失败:异常扫描:TypeError: 'undefined' is not an object

【问题讨论】:

  • 为什么不直接使用 iOS 的 BarcodeScanner 插件?

标签: javascript iphone cordova qr-code zxing


【解决方案1】:

您可以尝试以下方法:
1) 将 Cordova.plist 和 barcodescanner javascript 文件中的字符串 'org.apache.cordova.barcodeScanner' 更改为 'CDVBarcodeScanner'。
2) 在barcodescanner.js 中:
a) 将科尔多瓦更改为科尔多瓦
b) 在开头用 hasResource 和 addResource 注释行。

希望这会有所帮助。

【讨论】:

  • 我终于修好了,我会上传完整的项目供大家使用