To 提供对 Linea 设备系列的访问。
为了在您的程序中使用 Linea,必须执行几个步骤。这些步骤来自 2011 年,可能在 2017 年发生了变化,但出于历史目的在此处显示:
- Include LineaSDK.h and libdtdev.a in your project.
- Go to Frameworks and add ExternalAccessory framework
- Edit your program plist file, add new element and select
"Supported external accessory protocols" from the list, then add two items to it -
‘com.datecs.linea.pro.msr’ and ‘com.datecs.linea.pro.bar’
- Write code in MainViewController.m file to connect and retrieve barcode data.
1) 在您的项目中的 Classes 文件夹下包含“LineaSDK.h”和“libdtdev.a”。
2017 年更新:Download latest DTDEVICES SDK from developer.ipcmobile.com。截至 2017 年 1 月,最新版本为 v2.01,支持 Linea Pro 7 以上的设备。
2) 在您的项目中“添加现有框架”。
- 在项目导航器中,选择您的项目
- 选择您的目标。
- 选择“构建阶段”选项卡
- 打开“使用库链接二进制文件”扩展器
- 点击“+”按钮
- 选择“外部附件框架”
- 将添加的框架拖放到“框架”组中
3) 编辑您的项目 .plist 文件
<key>Supported external accessory protocols</key>
<value>
<array>
<string>com.datecs.linea.pro.msr</string>
<string>com.datecs.linea.pro.bar</string>
</array>
</value>
4) 在 MainViewController.m 文件中编写代码
//初始化linea类并连接它很重要
- (void)viewDidLoad
{
// init linea class and connect it
linea =[Linea sharedDevice];
[linea addDelegate:self];
[linea connect];
[super viewDidLoad];
}
//成功读取barode数据后调用
-(void)barcodeData:(NSString *)barcode type:(int)type {
// You can use this data as you wish
// Here I write barcode data into the console
NSLog(@"Barcode Data: %@”, barcode);
}
注意:将‘LineaSDK.h’导入你的MainViewController.h并声明
Linea* linea;
变量。
效果很好。