Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

didFinishWithResult is not getting invoked for MFMailComposeViewController

in buttonpress 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 press cancel button in the MailComposerView, delete is not getting invoked. what am i doing wrong ?

like image 596
Whoami Avatar asked Dec 11 '25 02:12

Whoami


1 Answers

  1. Set your viewController as a MFMailComposeViewControllerDelegate:

    @interface CurrentViewController : UIViewController <MFMailComposeViewControllerDelegate>
    
  2. Set your mailComposer delegate right after instantiation:

    MFMailComposeViewController * mailComposer = [[MFMailComposeViewController alloc]init];
    mailComposer.mailComposeDelegate = self;
    
like image 126
gps Avatar answered Dec 12 '25 15:12

gps



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!