gpt4 book ai didi

iphone - 将 UIImage 转换为 PDF 时应用程序崩溃

转载 作者:行者123 更新时间:2023-11-29 13:26:39 24 4
gpt4 key购买 nike

Apple 拒绝了我的应用,并附上这份报告:

http://nopaste.me/paste/173567898450806a3c774c4

我无法使用他们提到的相同设备和 iOS 进行重现,即 iPad 3 iOS6。

它们指的是将图像转换为 PDF 并通过电子邮件发送的功能。我使用此代码块来执行此操作:

-(IBAction)didPressSaveToPDFButton:(id)sender{

NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, imageView.bounds, nil);
UIGraphicsBeginPDFPage();
CGContextRef pdfContext = UIGraphicsGetCurrentContext();
[imageView.layer renderInContext:pdfContext];
UIGraphicsEndPDFContext();

NSLog(@"PDF");

MFMailComposeViewController *vc = [[MFMailComposeViewController alloc] init];
vc.mailComposeDelegate = self;
[vc setSubject:@"PDF"];
[vc addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"mypdf.pdf"];

[self presentModalViewController:vc animated:YES];
}

有人看到报告指向什么和/或错误在哪里吗?我看不出有什么问题。

符号化报告:

Last Exception Backtrace:
0 CoreFoundation 0x35e9729e __exceptionPreprocess + 158
1 libobjc.A.dylib 0x32d1f97a objc_exception_throw + 26
2 UIKit 0x327e213c -[UIViewController presentViewController:withTransition:completion:] + 3760
3 UIKit 0x32904252 -[UIViewController presentModalViewController:animated:] + 26
4 MyAppName 0x0009c5a2 -[ViewController didPressSaveToPDFButton:] (ViewController.m:200)
5 UIKit 0x327e10a8 -[UIApplication sendAction:to:from:forEvent:] + 68
6 UIKit 0x327e1130 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 116

最佳答案

因为您没有符号化您的崩溃日志,所以很难判断发生了什么。我的猜测是,您的 pdfContext 输出为 nil,而您正在尝试在具有 nil 上下文的图层中渲染您的 imageView。

我会努力

 if (pdfContext) {
[imageView.layer renderInContext:pdfContext];
}
else {
return;
}

关于iphone - 将 UIImage 转换为 PDF 时应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12963568/

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