我在我的应用程序中使用MFMailComposeViewController
撰写反馈电子邮件。显示MFMailComposeViewController
,但无法关闭。
用于打开MFMailComposeViewController
模态窗口的方法:
-(IBAction) feedbackBtnClicked:(id)sender {
// Dismiss the Old View Controller
[self dismissViewControllerAnimated:NO completion:NULL];
// Present the New View Controller
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
[mail setSubject:@"Sample Subject"];
[mail setMessageBody:@"Here is some main text in the email!" isHTML:NO];
[mail setToRecipients:@[@"example@mail.com"]];
[self presentViewController:mail animated:YES completion:NULL];
}
else
{
NSLog(@"This device cannot send email");
}
}
点击按钮时会发生以下情况:
Senden(发送) - 发送电子邮件,但模态窗口保持打开状态;多次单击该按钮会导致发送多个电子邮件,而模式窗口不会被关闭。 Abbrechen(取消) - 没有任何事情发生
如何解雇确保MFMailComposeViewController
在点击这些按钮后被解雇?
答案 0 :(得分:2)
您需要实施MFMailComposeViewControllerDelegate
方法mailComposeController:didFinishWithResult:error:
,并关闭邮件视图控制器......
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result
{
[self dismissViewControllerAnimated:YES completion:NULL];
}