Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MFMailComposeViewController's delegate not handling the CANCEL button [duplicate]

Possible Duplicate:
Action sheet doesn't display when the MFMailComposeViewController's cancel button is tapped

I've implemented standard mail functionality in my app according to the code sample provided by Apple.

I'm setting up the delegate as follows:

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

and I'm implementing

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 

Hitting the Send button invokes the delegate and it all works fine. However, hitting the Cancel button doesn't call the delegate and it just dims the view; the app hangs right there.

After reading similar threads here, I've been thinking that the view could be off-screen for some reason which is beyond my comprehension at this point. Note that the view is being created programmatically and is not using a xib file.

Any thoughts or ideas ?

like image 588
user628896 Avatar asked Dec 03 '22 06:12

user628896


1 Answers

You need to implement mailComposeController:didFinishWithResult:error delegate. And in that you dismiss the view which is showing your mail view. If you have opened the mail view as a modalView, then the way to dismiss this is -

- (void)mailComposeController:(MFMailComposeViewController*)controller 
          didFinishWithResult:(MFMailComposeResult)result
                        error:(NSError*)error 
{ 
    if(error) NSLog(@"ERROR - mailComposeController: %@", [error localizedDescription]);
    [self dismissModalViewControllerAnimated:YES];
    return;
}
like image 116
Srikar Appalaraju Avatar answered May 03 '23 23:05

Srikar Appalaraju