gpt4 book ai didi

iphone - 是否可以从 iPhone 和 iPad 应用程序打印?

转载 作者:太空狗 更新时间:2023-10-30 03:34:38 25 4
gpt4 key购买 nike

在我的应用程序中,如何允许用户从 iPhone 或 iPad 打印文档或页面?哪些版本的 iOS 支持打印?

最佳答案

这是一个简单的代码。

-(void)printItem {

UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *imageFromCurrentView = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController];
printController.printingItem = imageFromCurrentView;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGrayscale;
printController.printInfo = printInfo;
printController.showsPageRange = YES;


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 - 是否可以从 iPhone 和 iPad 应用程序打印?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4918783/

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