MFMailComposeViewController : cancel doesn't exit to my app?
Asked Answered
S

1

5

I'm trying to send a mail with MFMailComposeViewController. It happens when I click a button on my app. Of course when I click the Cancel button of the mail controller I want to go back to my app view but it doesn't work. What to do ? Here is my code :

MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"Subject"];
[controller setMessageBody:@"<html>Test</html>" isHTML:YES];
[controller setToRecipients:nil];
if(controller) [self presentModalViewController:controller animated:YES];

Thanks for your advices

Steen answered 12/6, 2012 at 8:8 Comment(0)
P
28

Have you implemented this delegate method? It's called after the composer is exited by the user.

- (void)mailComposeController:(MFMailComposeViewController*)controller 
      didFinishWithResult:(MFMailComposeResult)result
                    error:(NSError*)error 
{ 
    [self dismissViewControllerAnimated:YES completion:nil];
    return;
}
Pampero answered 12/6, 2012 at 8:17 Comment(2)
If that's fixed it for you then could you accept the answer? thanks.Pampero
dismissModalViewControllerAnimated is deprecated now, you should use dismissViewControllerAnimated insteadAlcatraz

© 2022 - 2024 — McMap. All rights reserved.