资讯专栏INFORMATION COLUMN

ionic QR Scanner常见问题解决

leanxi / 2439人阅读

摘要:解决办法全局搜索。要重新构建安卓平台不能扫码条形码问题此问题乃是编码格式的问题,扩充编码格式即可解决。解决办法全局搜索,找到文件,定位到定位到插件与插件冲突,导致黑屏。修改代码如下第一次进入扫描页面时页面没有透明第二次正常把代码放入。

1 扫码页面黑屏

1) src -> index.js。修改代码如下

</>复制代码


2)src -> theme -> variables.scss

</>复制代码

  1. // qrScanner
  2. ion-app.cameraView, ion-app.cameraView ion-content, ion-app.cameraView .nav-decor {
  3. background: transparent none !important;
  4. .tabbar.show-tabbar{
  5. opacity: 0;
  6. }
  7. }
  8. [app-viewport],
  9. [overlay-portal],
  10. [nav-viewport],
  11. [tab-portal],
  12. .nav-decor {
  13. display: none !important;
  14. background: none transparent !important;
  15. }
  16. html,
  17. body.transparent-body,
  18. .transparent-body,
  19. .transparent-body ion-app,
  20. .transparent-body .app-root,
  21. .transparent-body ion-nav,
  22. .transparent-body .ion-page,
  23. .transparent-body .nav-decor,
  24. .transparent-body ion-content,
  25. .transparent-body .viewscan,
  26. .transparent-body .fixed-content,
  27. .transparent-body .scroll-content {
  28. background-color: transparent !important;
  29. background: transparent none!important;
  30. }

多次扫码后摄像头发热的问题

</>复制代码

  1. this.qrScanner.hide(); // hide camera
  2. this.qrScanner.destroy(); // destory camera

2 QR Scanner安卓不能扫码条形码问题

此问题乃是编码格式的问题,扩充编码格式即可解决。
解决办法: 全局搜索formatList。找到QRScanner.java文件,定位到458行。

</>复制代码

  1. formatList.add(BarcodeFormat.UPC_A);
  2. formatList.add(BarcodeFormat.UPC_E);
  3. formatList.add(BarcodeFormat.EAN_13);
  4. formatList.add(BarcodeFormat.EAN_8);
  5. formatList.add(BarcodeFormat.CODE_39);
  6. formatList.add(BarcodeFormat.CODE_93);
  7. formatList.add(BarcodeFormat.CODE_128);
  8. formatList.add(BarcodeFormat.ITF);
  9. formatList.add(BarcodeFormat.DATA_MATRIX);


修改源代码后。要重新构建安卓平台

</>复制代码

  1. ionic cordova platform remove android
  2. ionic cordova platform add android

3 QR Scanner IOS不能扫码条形码问题

此问题乃是编码格式的问题,扩充编码格式即可解决。
解决办法:全局搜索metadataObjectTypes,找到QRScanner.swift文件,定位到156H

</>复制代码

  1. metaOutput!.metadataObjectTypes = [AVMetadataObjectTypeQRCode, AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeCode128Code, AVMetadataObjectTypeInterleaved2of5Code]


定位到241H

</>复制代码

  1. if [AVMetadataObjectTypeQRCode, AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeCode128Code, AVMetadataObjectTypeInterleaved2of5Code].contains(found.type) && found.stringValue != nil {
  2. scanning = false
  3. let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: found.stringValue)
  4. commandDelegate!.send(pluginResult, callbackId: nextScanningCommand?.callbackId!)
  5. nextScanningCommand = nil
  6. }

4 cordova-plugin-crosswalk-webview插件与QR插件冲突,导致黑屏

src -> index.js。修改代码如下

</>复制代码

5 第一次进入扫描页面时页面没有透明,第二次正常

把代码放入ionViewDidEnter。当进入页面时触发

</>复制代码

  1. ionViewDidEnter() {
  2. (window.document.querySelector("ion-app") as HTMLElement).classList.add("cameraView");
  3. this.isShow = true;
  4. var cs = (window.document.querySelector("ion-app") as HTMLElement).classList.contains("cameraView");
  5. console.log(cs);
  6. }
  7. }

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/104615.html

相关文章

  • Java编程基础35——学生管理系统

    摘要:视图层表示层数据传递给层实现接收用户输入并调用打印菜单获取用户输入调用对应方法欢迎来到学生管理系统添加用户编辑用户查询用户删除用户退出系统请输入要操作的功能序号接收用户的菜单选择对选择的菜单判 showImg(https://segmentfault.com/img/bVbiXjw?w=939&h=509); 1.视图层 package net.allidea.studentoa.ui...

    mingde 评论0 收藏0

发表评论

0条评论

leanxi

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<