MFMailComposeViewController检查是否按下发送

时间:2014-06-12 14:32:51

标签: objective-c email uiviewcontroller sendmail

在使用MFMailComposeViewController类时,有没有办法检查用户是否实际按下了发送按钮?

由于

1 个答案:

答案 0 :(得分:1)

使用MFMailComposeViewControllerDelegate(https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMailComposeViewControllerDelegate_protocol/Reference/Reference.html

-(void)sendMail
{
  MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
  [mailer setMailComposeDelegate:self];
  //do the rest of the mail composing
  ...
}

-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
  //don't forget to dismiss the controller
  [controller dismissModalViewControllerAnimated:YES];

  if(result == MFMailComposeResultSent)
  {
    //the user sent the mail
  }
}