當我運行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