iOS蓝牙打印

蓝牙打印的几个主要步骤:
1.扫描蓝牙 (打印机有蓝牙功能并开启)
- (IBAction)scanlPrint:(UIButton *)sender {
    
    [uartLib scanStart];
    
}
2.连接蓝牙 (停止扫描)
- (IBAction)connectPrint:(UIButton *)sender {
    
    NSLog(@"connect Peripheral");
    [uartLib scanStop];
    [uartLib connectPeripheral:connectPeripheral];
    
    [connectAlertView show];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(printInput) name:@"printBill" object:nil];


}
3.打印 (格式不易控制)
- (void)printInput{
    NSString *curPrintContent;
    
    curPrintContent = [sendDataView text];
    
    NSString * curPrintContent = @"打印测试这里有好长一段话,还是看不到呀,要不然我看不到,这里是什么格式";
        if ([curPrintContent length]) {
            NSString *printed = [curPrintContent stringByAppendingFormat:@"%c%c%c", '\n', '\n', '\n'];
            [self PrintWithFormat:printed];
    }
}


用了UartLib的SDK
所以要导入UartLib的头文件,设置delegate,代理里面的方法必须实现,还有加入必要的成员变量

你可能感兴趣的:(iOS蓝牙打印)