다음은 내 애플리케이션에 사용하는 것입니다. 이것은 iOS 7에서는 정상적으로 작동하지만 iOS 8에서는 충돌이 발생합니다.PDF를 생성하는 동안 UIGraphicsEndPDFContext를 호출 할 때 iOS 8에서 충돌이 발생합니다.
이 방법을 사용하여 스크린 샷을 찍은 다음 pdf를 작성하여 이메일로 전송합니다.
-(void)createPDFfromUIView:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename
{
// Creates a mutable data object for updating with binary data, like a byte array
NSMutableData *pdfData = [NSMutableData data];
// Points the pdf converter to the mutable data object and to the UIView to be converted
UIGraphicsBeginPDFContextToData(pdfData, aView.bounds, nil);
UIGraphicsBeginPDFPage();
CGContextRef pdfContext = UIGraphicsGetCurrentContext();
// draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData
[aView.layer renderInContext:pdfContext];
// remove PDF rendering context
UIGraphicsEndPDFContext();
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:30.0/255.0 green:172.0/255.0 blue:254.0/255.0 alpha:1]];
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"Payment Receipt"];
[mailer addAttachmentData:pdfData mimeType:@"application/pdf" fileName:[NSString stringWithFormat:@"%@",aFilename]];
NSString *emailBody = @"Payment Receipt";
[mailer setMessageBody:emailBody isHTML:NO];
[[mailer navigationBar] setTintColor:[UIColor whiteColor]];
[self presentViewController:mailer animated:YES completion:nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email error!"
message:@" You do not have an email address configured in your device"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
나는 그것이 UIGraphicsEndPDFContext()
에서 정지 볼 수있는 예외 중단 점을 추가
없이 성공 솔루션을 지난 3 일 찾기 위해 노력하고있다.
가 관련된 이메일 opition 만들기 오류? – usr2564301
그들은 오류의 일부가 아닙니다. 그러나 완전한 가시성을 제공하므로 전체 코드를 배치해도 아무런 해가 없습니다. –