私はUIPrintInteractionControllerに問題があります.PDFを送信して印刷し、iOS 5のデバイスでは印刷ボタンを押すとファイルがプリンターに送信され、機能します。しかし、ios 6 を搭載したデバイスでテストすると、機能せず、アプリがクラッシュします。
iOS 6 で表示される UIPrintInteractionController のビューは、次のログです。
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 を使用してサファリで印刷できます。
誰が何が悪いのか知っていますか? =(