我尝试使用这个librairy来使用iOS上的条形码扫描器:https://github.com/codenameone/cn1-codescan --它在Android上工作得很好--但是当我的应用程序在iOS上打开相同的条形码扫描表单时,我的应用程序就会关闭,而不会显示任何错误消息。我要扫描128个条形码。也许我必须编辑这个属性,特别是对于IOS?
这是我的代码:
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));
}
});
}编辑:这里是构建提示:
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空气。
发布于 2019-05-22 02:16:11
确保您的cn1lib是最新的,并且您也在模拟器上运行它。您需要定义ios.NSCameraUsageDescription构建提示(如果直接编辑文件,则需要定义codename1.arg.ios.NSCameraUsageDescription )。这是当前版本的iOS所必需的。当您在模拟器中运行代码时,库将隐式地添加此内容。
https://stackoverflow.com/questions/56188555
复制相似问题