gpt4 book ai didi

ios - 从 UIWebview 应用程序崩溃创建 pdf 时

转载 作者:可可西里 更新时间:2023-11-01 06:04:38 26 4
gpt4 key购买 nike

我想将 UIWebview (height = 4224,width = 568) 转换为 pdf 以通过邮件发送,当我使用下面的代码应用程序在这一行崩溃时 ([self. reportWebView.layer renderInContext:UIGraphicsGetCurrentContext()])。请给我一些好的建议。谢谢。

    CGRect frame = self.reportWebView.frame;
CGSize fittingSize = [self.reportWebView sizeThatFits:CGSizeZero];
frame.size = fittingSize;
self.reportWebView.frame = frame;

NSMutableData *pdfData = [NSMutableData data];
@autoreleasepool {
// Points the pdf converter to the mutable data object and to the UIView to be converted
UIGraphicsBeginPDFContextToData(pdfData, self.reportWebView.bounds, nil);
UIGraphicsBeginPDFPage();
[self.reportWebView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndPDFContext();
}

最佳答案

您以错误的方式呈现上下文。

代替

[self.reportWebView.layer UIGraphicsGetCurrentContext()];

试试这个

self.reportWebView.layer.renderInContext(UIGraphicsGetCurrentContext())

关于ios - 从 UIWebview 应用程序崩溃创建 pdf 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33735796/

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