1

我正在打印当前显示的屏幕视图,iPhone如下所示。但由于某种原因,屏幕的某些部分正在修剪,任何人都可以建议下面的代码有什么问题

注意:我autolayout在我的view. 附上屏幕截图。

-(void)printItem {

    UIGraphicsBeginImageContext(self.view.bounds.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();


    UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController];

    if(printController ) {

        printController.delegate = self;

        UIPrintInfo *printInfo = [UIPrintInfo printInfo];
        printInfo.outputType = UIPrintInfoOutputGeneral;
        printInfo.jobName = @"resultado";
        printInfo.duplex = UIPrintInfoDuplexLongEdge;
        printController.printInfo = printInfo;
        printController.showsPageRange = YES;
        printController.printingItem = newImage;

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

        [printController presentAnimated:YES completionHandler:completionHandler];

    }
}

模拟器视图 在此处输入图像描述

打印视图(内容修剪关闭)

在此处输入图像描述

4

0 回答 0