gpt4 book ai didi

iphone - 使用 UIPrintInteractionController 打印 PDF ios 5 有效,但在 ios 6 中不起作用并使我的应用程序崩溃

转载 作者:太空狗 更新时间:2023-10-30 03:45:33 25 4
gpt4 key购买 nike

我在使用 UIPrintInteractionController 时遇到问题 我发送了一个 pdf 来打印,当我按下打印按钮将文件发送到打印机并工作时,我使用带有 ios 5 的设备发送了一个问题。但是当我在装有 ios 6 的设备上进行测试时,我无法正常工作并导致应用程序崩溃。

当 UIPrintInteractionController 的 View 出现在 ios 6 上时,这是日志:

Save\032in\032folder\032Aptana\032Rubles._ipp._tcp.local.:
Get-Printer-Attributes failed: Undefined error: 0
No document-format-supported attribute found or no supported formats
found.
No media-col-database found in response from printer.
Defaulting to generic media size values.
No print-quality-supported attribute found. Defaulting to normal
quality.
No sides-supported attribute found. Defaulting to single-sided.

这是我的代码:(self.myPDF 是一个 NMutableSData 类型)

UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController];

if (controller && [UIPrintInteractionController canPrintData: self.myPDF] ) {



UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = [NSString stringWithFormat:@"Coupon"];
printInfo.orientation = UIPrintInfoOrientationPortrait;
printInfo.duplex = UIPrintInfoDuplexLongEdge;

controller.printInfo = printInfo;
controller.showsPageRange =NO;

controller.printingItem = self.myPDF;

void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
if (!completed && error) {

UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Error."
message:[NSString stringWithFormat:NSLocalizedString(@"An error occured while printing: %@", @"Printing error"), error]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];

[av show];
[av release];
}
};

[controller presentAnimated:YES completionHandler:completionHandler];
}

我没有支持 AirPrint 的打印机,但我使用了 handyPrint。注意:在 iOS 6 上,它可以使用 handyPrint 通过 safari 进行打印。

谁知道哪里出了问题? =(

最佳答案

使用 Xcode 附带的 AirPrint 打印机模拟器对其进行测试。这个问题很可能出在 handyPrint 不支持 AirPrint 的新功能上。

关于iphone - 使用 UIPrintInteractionController 打印 PDF ios 5 有效,但在 ios 6 中不起作用并使我的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17218689/

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