Objective c 无法向XPrinter发送命令
我向xPrinter发送命令时遇到问题。我有其iOS应用程序SDK,并按照此框架中的说明通过WIFI连接成功将iOS应用程序连接到此打印机Objective c 无法向XPrinter发送命令,objective-c,frameworks,thermal-printer,Objective C,Frameworks,Thermal Printer,我向xPrinter发送命令时遇到问题。我有其iOS应用程序SDK,并按照此框架中的说明通过WIFI连接成功将iOS应用程序连接到此打印机 NSString * ip = "IPAddress"; [manager MConnectWithHost:ip port:9100 completion: ^(BOOL result){ }]; -->已创建管理器并成功连接 但当通过MWIFIManager类的MWRITECOMANDWITHDATA方法发送命令时,它总是将字符串打印出来,而不是将
NSString * ip = "IPAddress";
[manager MConnectWithHost:ip port:9100 completion: ^(BOOL result){
}];
-->已创建管理器并成功连接
但当通过MWIFIManager类的MWRITECOMANDWITHDATA方法发送命令时,它总是将字符串打印出来,而不是将命令打印到打印机
例如:
我想通过为TscCommnand准备cmd来剪切页面:
NSData *data = [TscCommand cut]
然后通过以下方式将其发送给MWIFIManager:
[manager MWriteCommandWithData:data];
结果:它将“剪切”打印到打印机的纸张上,而不是剪切纸张
我从这里下载的SDK:
它是由Objective C编写的,我的iOS应用程序是由Swift开发的。
我只想实现一种方法来连接并在XPrinter(热敏打印机)上打印
任何有这方面经验的人请提出建议。非常感谢 不确定您要对IP地址做什么 以下是您需要在iOS中打印的所有内容: 类printInteractionController=NSClassFromString(@“UIPrintInteractionController”)
if ((printInteractionController != nil) && [printInteractionController isPrintingAvailable])
{
NSURL *fileURL = document.fileURL; // Document file URL
printInteraction = [printInteractionController sharedPrintController];
if ([printInteractionController canPrintURL:fileURL] == YES) // Check first
{
UIPrintInfo *printInfo = [NSClassFromString(@"UIPrintInfo") printInfo];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = document.fileName;
printInteraction.printInfo = printInfo;
printInteraction.printingItem = fileURL;
printInteraction.showsPageRange = YES;
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
[printInteraction presentFromRect:button.bounds inView:button animated:YES completionHandler:
^(UIPrintInteractionController *pic, BOOL completed, NSError *error)
{
#ifdef DEBUG
if ((completed == NO) && (error != nil)) NSLog(@"%s %@", __FUNCTION__, error);
#endif
}
];
}
else // Presume UIUserInterfaceIdiomPhone
{
[printInteraction presentAnimated:YES completionHandler:
^(UIPrintInteractionController *pic, BOOL completed, NSError *error)
{
#ifdef DEBUG
if ((completed == NO) && (error != nil)) NSLog(@"%s %@", __FUNCTION__, error);
#endif
}
];
}
}
}