手机蓝牙连接GPrinter打印机进行打印 iOS
sdk下载地址:https://www.poscom.cn/down-show-82.html
代码下载:https://download.****.net/download/wulitc/11168505
一、打印机通过蓝牙连接手机设备
新建蓝牙管理类:LMBluetoothManeger
LMBluetoothManeger.h文件
LMBluetoothManeger.m文件
二、设置打印机的内容与打印
1.新建打印机管理类:LMPrinterManeger
2.新建工具类:LMPrintCommand (继承EscCommand类)
3.新建消费Model类:LMPrinterModel
LMPrinterManeger.h
LMPrinterManeger.m
LMPrintCommand.h文件
LMPrintCommand.m文件
LMPrinterModel.h文件
三、找到蓝牙后连接
/**连接蓝牙设备*/
- (void)bluetoothlinkWithPeripheral:(CBPeripheral *)peripheral;
然后就直接调用LMPrinterManeger里的相应方法
nameArr:是服务器返回的数据
NSArray *arr = @[@"用户人:yy",@"下单时间:2019-05-09 11:11",@"完成时间:2019-05-09 13:13",@"订单编号:9527"];
NSMutableArray * parr =[NSMutableArray new];
if (nameArr.count) {
for (int i =0 ; i<nameArr.count; i++) {
LMPrinterModel *model =[[LMPrinterModel alloc]init];
model.name = nameArr[i];
model.price = priceArr[i];
[parr addObject:model];
}
}
[[LMPrinterManeger sharedInstance] custombillprintWithArr:arr Arr:[NSArray arrayWithArray:parr]];
//二维码
[[LMPrinterManeger sharedInstance] QRcode_label:@"二维码内容"]];
效果图: