当我运行Xcode 6并使用iOS 8模拟器时,我试图加载一个MFMailComposeViewController,它没有出现。相反,我得到这个错误...MFMailComposeViewController不显示在iOS 8中
“警告:试图提出MFMailComposeViewController:0x7c30c400上的ViewController:0x7baf6000这已经是呈现(空)”
这完全相同的代码已经工作了将近一年了,不变。 可以肯定的是,我使用iOS 7.1模拟器在Xcode 6中运行我的应用程序,它的工作方式与以前完全一样。
有谁知道如何在iOS 8中显示MFMailComposeViewController视图? 这看起来像一个简单的任务,我相信它是一个简单的修复。
PS。不需要发帖,因为它是标准的代码,但在这里它是无论如何...
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
//Current Date
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
NSDate *date = [NSDate date];
//Ensure UTC DATE
[formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
[formatter setDateFormat:@"MM/dd/yyyy 'at' HH:mm:ss UTC"];
NSString *myString = [formatter stringFromDate:date];
NSString *emailBody = [NSString stringWithFormat:@"Feedback time at %@.<br><br>Name:", myString];
[picker setMessageBody:emailBody isHTML:YES];
NSString *subject, *emailAddress;
[formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
[formatter setDateFormat:@"MM/dd/yyyy"];
subject = [NSString stringWithFormat:@"Feedback"];
//Set the Subject
[picker setSubject:subject];
emailAddress = @"[email protected]";
//Set the Receivers
NSArray *myReceivers = [[NSArray alloc] initWithObjects:emailAddress, nil];
[picker setToRecipients:myReceivers];
//It saves the file name as the same as Subject here!
picker.navigationBar.barStyle = UIBarStyleDefault;//UIBarStyleBlack;
[self presentViewController:picker animated:YES completion:^{}];
就是这样。我还从UIPopover上展示了它,并且在打开MailComposer之前添加了该行以解除它,并且它工作正常!谢谢 – Airtower 2014-09-23 02:02:33