phonegap 使用插件实现扫描
我什么环境插件都搞好了就是不能进行扫描请问这是为什么急急急 希望你们能帮我谢谢
1、把所需要的.cpp .mm等导入Plugins中如图
http://img.bbs.csdn.net/upload/201504/24/1429855568_466584.png
2、在config.xml中加入一段代码并HTML中进行了引用.jsconfig.xml中
<feature name="BarcodeScanner">
<param name="ios-package" value="CDVBarcodeScanner" />
</feature>
HTML中
<!DOCTYPE HTML><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>收件扫描</title><link href="../jquery-mobile-1.4.5/jquery.mobile-1.4.5.min.css" rel="stylesheet" type="text/css"/><link href="../scan/scan.css" rel="stylesheet" type="text/css"/><script src="../jquery-mobile-1.4.5/jquery-1.8.3.min.js" type="text/javascript"></script><script src="../jquery-mobile-1.4.5/jquery.mobile-1.4.5.min.js" type="text/javascript"></script><script src="../cordova.js" type="text/javascript"></script><script src="../db/db.js" type="text/javascript"></script><script src="receiverScan.js" type="text/jscript"></script><script src="Toast.js" type="text/javascript"></script><script src="barcodescanner.js" type="text/javascript"></script></head>
3、把js文件导入www包的html文件夹中(第一个就是)
http://img.bbs.csdn.net/upload/201504/24/1429855641_162479.png
4、JS代码中如下
cordova.plugins.barcodeScanner.scan(
function (result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
function (error) {
alert("Scanning failed: " + error);
}
);
5、通过try catch 捕获到异常
function loadBill(){
alert("扫描"); try{ var scanner =window.plugins.barcodeScanner scanner.scan(function (result) { alert("We got a barcode\n" + "Result: " + result.text + "\n" + "Format: " + result.format + "\n" + "Cancelled: " + result.cancelled); }, function (error) { alert("Scanning failed: " + error); } ); }catch(error){ alert(error.message); }
}
http://img.bbs.csdn.net/upload/201504/24/1429857443_604285.png
我都这样搞了还是不行 坑啊 ~~~~~~~~!
原来的js我也出现这种问题,改过就行了http://pan.baidu.com/s/1o62yDUq(我改过的js,修改、直接调用scanCode());还有<framework src="libiconv.dylib" />
<framework src="AVFoundation.framework" />
<framework src="AssetsLibrary.framework" />
<framework src="CoreVideo.framework" />
<framework src="QuartzCore.framework" />
<framework src="CoreGraphics.framework" />
<framework src="CoreImage.framework" />
<framework src="AudioToolbox.framework" />这几个包也要引入到项目中哦 看看这个帖子 官方的二维码插件
http://bbs.phonegap100.com/thread-1565-1-1.html
第三方的二维码插件
http://bbs.phonegap100.com/thread-324-1-1.html
页:
[1]