首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >条形码扫描库在iOS上不工作,但在Android上工作

条形码扫描库在iOS上不工作,但在Android上工作
EN

Stack Overflow用户
提问于 2019-05-17 14:31:43
回答 1查看 110关注 0票数 1

我尝试使用这个librairy来使用iOS上的条形码扫描器:https://github.com/codenameone/cn1-codescan --它在Android上工作得很好--但是当我的应用程序在iOS上打开相同的条形码扫描表单时,我的应用程序就会关闭,而不会显示任何错误消息。我要扫描128个条形码。也许我必须编辑这个属性,特别是对于IOS?

这是我的代码:

代码语言:javascript
复制
public class ScanCode extends Form {
final Container cnt = this;
public ScanCode(Form parent){
    this.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    Display.getInstance().setProperty("android.scanTypes", "CODE_128");
    CodeScanner.getInstance().scanBarCode(new ScanResult() {
        public void scanCompleted(String contents, String formatName, byte[] rawBytes) {
            String word;
            word= contents.substring(0,12);
            List<Patient> myList= new ArrayList<>();
            myList= RestManager.getList(contents.substring(0,12));
            if(myList.size()==0){
                new ManualInfo(parent,contents).show();
            }
            else{
                Date date = new Date();
                Intervention intervention = new Intervention();
                intervention.setList(myList.get(0));
                intervention.setDateAction(date);
                intervention.setDateCreate(date);
                intervention.setDateUpdate(date);
                intervention.setEncodingType(Intervention.BARCODE_TYPE);
                Update ajoutintervention = new Update();
                ajoutintervention.setId((long) 0);
                ajoutintervention.setDatas(intervention.toJson());
                ajoutintervention.setDateCreate(date);
                ajoutintervention.setDateUpdate(date);
                ajoutintervention.setTreatment(String.valueOf(Constants.INSERT));
                ajoutintervention.setDone(String.valueOf(false));
                ajoutintervention.setClassName(intervention.getName());
                ajoutintervention.setParam(myList.get(0).getWord());
                DatabaseHelper.saveDataClass(ajoutintervention);
            }

        }

        public void scanCanceled() {
            cnt.addComponent(new Label("cancelled"));
        }

        public void scanError(int errorCode, String message) {
            cnt.addComponent(new Label("err " + message));
        }
    });        
}

编辑:这里是构建提示:

代码语言:javascript
复制
codename1.arg.ios.add_libs=ExternalAccessory.framework;CoreBluetooth.framework;libc++.dylib;SystemConfiguration.framework;,libc++.dylib,CoreText.framework,MessageUI.framework,CoreVideo.framework,CoreMedia.framework    
codename1.arg.ios.background_modes=,bluetooth-central,bluetooth-peripheral
codename1.arg.ios.debug.archs=arm64
codename1.arg.ios.includePush=true
codename1.arg.ios.newStorageLocation=true
codename1.arg.ios.plistInject=<key>NSBluetoothPeripheralUsageDescription</key><string>This app uses a BLE cardreader</string><key>UISupportedExternalAccessoryProtocols</key><array><string>bt.reader.library</string></array> <key>NSAppTransportSecurity</key> <dict><key>NSAllowsArbitraryLoads</key><true/></dict>   
codename1.arg.ios.pods.platform=8.0,7.0
codename1.arg.ios.pods.sources=https\://github.com/CocoaPods/Specs.git
codename1.arg.ios.xcode_version=10.1
codename1.arg.java.version=8

我工作的12.1 iOS版本,该设备是一个iPad空气。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-22 02:16:11

确保您的cn1lib是最新的,并且您也在模拟器上运行它。您需要定义ios.NSCameraUsageDescription构建提示(如果直接编辑文件,则需要定义codename1.arg.ios.NSCameraUsageDescription )。这是当前版本的iOS所必需的。当您在模拟器中运行代码时,库将隐式地添加此内容。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56188555

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档