“警告:尝试在已经呈现(null)的ViewController:0x7baf6000上呈现MFMailComposeViewController:0x7c30c400。”
这完全相同的代码已经工作了将近一年了,没有改变。为了确保,我在Xcode 6中使用iOS 7.1模拟器运行我的应用程序,它像以前一样完美地工作。
有人知道如何在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 = @"xxx@example.com";
//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:^{}];