是否可以在全页UIScrollview上进行空气打印?

时间:2011-05-03 07:52:55

标签: uiscrollview airprint

我长期陷入这个问题。正如我所问,我可以打印滚动视图但只能打印一部分,而不是全尺寸视图“contentView”。

代码是这样的:

if ([UIPrintInteractionController isPrintingAvailable])
{
    UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
    UIGraphicsBeginImageContext(sv.contentSize);

    [sv.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    NSData *myData = [NSData dataWithData:UIImagePNGRepresentation(viewImage)];
    if(pic && [UIPrintInteractionController canPrintData: myData] ) {

        pic.delegate =(id<UIPrintInteractionControllerDelegate>) self;

        UIPrintInfo *printInfo = [UIPrintInfo printInfo];
        printInfo.outputType = UIPrintInfoOutputGeneral;
        printInfo.jobName = [NSString stringWithFormat:@"QFTicket-%@",self.payment.id];
        printInfo.duplex = UIPrintInfoDuplexLongEdge;
        pic.printInfo = printInfo;
        pic.showsPageRange = YES;
        pic.printingItem = myData;
        pic.printFormatter=[sv viewPrintFormatter];

        void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
            if (!completed && error) {
                NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code);
            }
        };

        [pic presentAnimated:YES completionHandler:completionHandler];

    }

}

我错过了什么吗?

THX

0 个答案:

没有答案