Somewhere:
if([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *email_vc = [[MFMailComposeViewController alloc] init];
email_
I guess the action sheet gets the dismiss message instead of the mail compose view controller.
Not quite.
The sequence of events probably happens like this:
-actionSheet:clickedButtonAtIndex:
on its delegate (the MFMCVC).
-mailComposeController:didFinishWithResult:error:
on its delegate (your VC)
[self dismissModalViewControllerAnimated:NO]
-actionSheet:didDismissWithButtonIndex:
on its delegate
The fix would be for Apple to do actionSheet.delegate = nil
in -dealloc
.
A potential workaround
[[self.modalViewController retain] autorelease]
[self dismissModalViewControllerAnimated:NO]
This is a bit trickier to do if you are using ARC.
this works for me:
- (void) mailComposeController: (MFMailComposeViewController *) controller
didFinishWithResult: (MFMailComposeResult) result
error: (NSError *) error {
if(result == MFMailComposeResultSent){
[self dismissViewControllerAnimated:YES completion:NULL];
} else if (result == MFMailComposeResultCancelled) {
[self dismissViewControllerAnimated:YES completion:NULL];
}
}