This is very old iOS4 code and try to find the bug when the mail compose controller crashes in iOS9
#pragma mark - Export song
- (IBAction)tapExportButton:(id)sender
{
[self dismissAllPopovers];
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
NSString *songDescription = self.songViewController.song.getSongDescription;
[mailer setSubject:[NSString stringWithFormat:@"Chords+Lyrics %@: %@",NSLocalizedString(@"Song", nil),songDescription]];
// Build the attachment. The current song in import/export format.
FileExporter *fileExporter = [[FileExporter alloc]init];
NSData *attachData = [[NSData alloc]init];
if ([fileExporter encodeExportFormat:
[fileExporter songIntoExportFormat:self.songViewController.song]
intoMailAttachment:&attachData]) {
[mailer addAttachmentData:attachData mimeType:@"text/plain" fileName:[NSString stringWithFormat:@"%@.song",songDescription]];
}
NSString *emailBody = [NSString stringWithFormat: NSLocalizedString(@"This song is send to you from the Chords+Lyrics App.", nil) ];
[mailer setMessageBody:emailBody isHTML:NO];
mailer.modalPresentationStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:mailer animated:YES completion: NULL];
[mailer release];
[fileExporter release];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
message:@"Your device doesn't support the composer sheet"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
There are some solutions MFMailComposeViewController throws an error only in iOS 9 about Font problems in UINavigationBar, but that's not working for me...
log:
2016-06-23 14:23:59.883 +[NSManagedObjectContext(ActiveRecord) contextWithStoreCoordinator:](5d67a58) Creating MOContext *** On Main Thread ***
2016-06-23 14:23:59.901 -[SongViewController viewDidLoad]: called
2016-06-23 14:24:02.034 viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
2016-06-23 14:24:02.537 -[RootViewController mailComposeController:didFinishWithResult:error:]: Mail cancelled: you cancelled the operation and no email message was queued.
2016-06-23 14:24:02.537 Trying to dismiss the presentation controller while transitioning already. (<_UIFullscreenPresentationController: 0x7fed2a8f4a20>)
2016-06-23 14:24:02.540 transitionViewForCurrentTransition is not set, presentation controller was dismissed during the presentation? (<_UIFullscreenPresentationController: 0x7fed2a8f4a20>)
Regards, jr00n