我正在打印到QLn420,它在调试器下工作得很好,或者当传递非常少量的ZPL但是当我在调试器下运行应用程序时它失败了。代码与Zebra的演示代码(https://km.zebra.com/kb/index?page=content&id=WH122&actp=LIST)基本相同,只是在调用栈中先前执行了dispatch_async。
NSString *serialNumber = [ZebraPrintManager getBluetoothSerial];
// Instantiate connection to Zebra Bluetooth accessory
id<ZebraPrinterConnection, NSObject> thePrinterConn = [[MfiBtPrinterConnection alloc] initWithSerialNumber:serialNumber];
// Open the connection - physical connection is established here.
BOOL success = [thePrinterConn open];
NSError *error = nil;
// Send the data to printer as a byte array.
NSData* data = [ZPL dataUsingEncoding:NSUTF8StringEncoding];
success = success && [thePrinterConn write:data error:&error];
dispatch_async(dispatch_get_main_queue(), ^{
if(success != YES || error != nil) {
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[errorAlert show];
}
});
// Close the connection to release resources.
[thePrinterConn close];
答案 0 :(得分:0)
蓝牙有延迟设置。将此值增加到至少100.某些手机无法使用设置为30的值。