DidFinishWithResult not called for MFMailComposeViewController

in the button callback:

 MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
    mailViewController.mailComposeDelegate = self;

    [self presentModalViewController:mailViewController animated:YES];

Delegate Implementation:

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
NSLog (@" Inside  MAIL COMPOSER CONTROLLER DELIGATE ");


// Remove the mail view
[self dismissModalViewControllerAnimated:YES];
}

When I click the cancel button in MailComposerView, the deletion is not called. what am I doing wrong?

+3
source share
2 answers
  • Set your viewController as MFMailComposeViewControllerDelegate:

    @interface CurrentViewController : UIViewController <MFMailComposeViewControllerDelegate>
    
  • Install the mailComposer delegate immediately after creating the instance:

    MFMailComposeViewController * mailComposer = [[MFMailComposeViewController alloc]init];
    mailComposer.mailComposeDelegate = self;
    
+1
source

Have you really made your MFMailComposeViewControllerDelegate class?

@interface MyViewController : UIViewController <MFMailComposeViewControllerDelegate>
0
source

All Articles