0
這是很老的iOS4的代碼,並試圖找到錯誤時iOS9郵件撰寫控制器死機,因爲iOS的9運行時MFMailComposeViewController不是在舊的iOS代碼爲我工作
#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];
}
有一些解決方案MFMailComposeViewController throws an error only in iOS 9 約字體問題UINavigationBar的,但是這不是爲我工作...
日誌:
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>)
問候, jr00n