gpt4 book ai didi

ios - UIPrintInteractionController 打印到多台 AirPrint 打印机

转载 作者:行者123 更新时间:2023-11-28 23:39:15 36 4
gpt4 key购买 nike

我遇到的一个真正令人沮丧的事情是无法同时打印到多台 AirPrint 打印机。不要将这与在一台打印机上打印多个 ITEMS 相混淆。

例子:
我们有 3 台 AirPrint 打印机。
每台打印机都需要打印一些东西……一个接一个。

如果你已经有了你的 UIPrinter 对象,你会调用:

- (BOOL)printToPrinter:(UIPrinter *)printer 
completionHandler:(UIPrintInteractionCompletionHandler)completion;

在完成方法中,正常的过程是像这样在完成方法中触发下一个作业:

- (void)printAllJobs

// let's use an example printer url:
UIPrinter *printer = [[UIPrinter alloc] initWithURL:[NSURL URLWithString:@"ipps://mycomputer.:863/printers/label"]];

// get the printer interaction controller:
UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController];

// now print:
[controller printToPrinter:printer completionHandler:^(UIPrintInteractionController * _Nonnull printInteractionController, BOOL completed, NSError * _Nullable error) {

// here.. you would check if the job is complete:
if (completed) {

// print to the next printer:
// THIS METHOD GETS FIRED BUT DOESN'T ACTUALLY PRINT
[self printToNextPrinter];

}

}

}

- (void)printToNextPrinter {

// create next printer:
UIPrinter *nextPrinter = [[UIPrinter alloc] initWithURL:[NSURL URLWithString:@"ipps://mycomputer.:863/printers/roller"]];

// get controller:
UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController];

// print:
[controller printToPrinter:printer completionHandler:^(UIPrintInteractionController * _Nonnull printInteractionController, BOOL completed, NSError * _Nullable error) {

// this never gets executed.

}

}

最佳答案

我发现了什么:
发生这种情况时会发生一件值得注意的事情;屏幕上显示一个 UIAlertController,上面写着“Printing to.. xxx”——显示打印进度。

解决方案:
解决方案是每 2 秒检查一次,看看屏幕上是否有可见的警报。如果有,重复相同的方法,如果没有,则启动下一个打印作业。似乎 Apple 不允许在没有警报的情况下进行后台打印,所以这是唯一的方法.. 除了深入研究 CUPS 之外,这将是一团糟。

关于ios - UIPrintInteractionController 打印到多台 AirPrint 打印机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54026117/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com