gpt4 book ai didi

iPhone : Print all contents of a Scroll View

转载 作者:行者123 更新时间:2023-11-29 11:15:48 25 4
gpt4 key购买 nike

我需要你的帮助。我已经阅读了苹果关于打印的文档,但是我很难理解如何打印 ScrollView 的所有内容。我知道到目前为止检查打印机是否可用

//-----------Check for printer-------------------
if ([UIPrintInteractionController isPrintingAvailable]) {
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
target:self
action:@selector(printWebView:)];

[self.navigationItem setLeftBarButtonItem:barButton animated:NO];
self.printButton = barButton;
}

如果有人能提供实际打印作业的代码,我将不胜感激。提前致谢...

最佳答案

抓取屏幕截图并打印

/* 抓取屏幕截图并打印*/

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

}
}

关于iPhone : Print all contents of a Scroll View,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9473817/

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