6

I have a problem with UIPrintInteractionController I send a pdf to print and with a devices with ios 5 when i press print button is send the file to the printer and works. but when I test on a devices with ios 6 I doesn't work and crash the app.

when the view of the UIPrintInteractionController presented on ios 6 this is the log:

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.

Here is my Code: (self.myPDF is a NMutableSData type)

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];
}

i dont have a AirPrint supported Printer but i used the handyPrint. Note: on iOS 6 it works printing with safari using handyPrint.

Anyone Knows what is wrong? =(

4

1 回答 1

1

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

于 2013-08-22T05:36:49.843 回答