Unable to dismiss MFMailComposeViewController, delegate not called

Posted by Rod on Stack Overflow See other posts from Stack Overflow or by Rod
Published on 2009-12-16T23:58:31Z Indexed on 2010/12/25 13:54 UTC
Read the original article Hit count: 191

HI, I am calling MFMailComposeViewController from UITableViewController. Problem is, delegate method mailComposeController:(MFMailComposeViewController)controllerdidFinishWithResult* is never called when I select Cancel or Send button in Mail compose window.

Here is the table view class:

@implementation DetailsTableViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section==0 && indexPath.row==4){
    	//SEND MAIL
    	MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
    	controller.mailComposeDelegate = self;
    	if ([MFMailComposeViewController canSendMail]) {
    		[controller setSubject:[NSString stringWithFormat:@"Ref %@",[item objectForKey:@"reference"]]];
    		[controller setMessageBody:@" " isHTML:NO]; 
    		[controller setToRecipients:[NSArray arrayWithObject:[item objectForKey:@"email"]]]; 
    		[self presentModalViewController:controller animated:YES];
    	}
    	[controller release];		
    }
}

- (void)mailComposeController:(MFMailComposeViewController*)controllerdidFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
// NEVER REACHES THIS PLACE
    [self dismissModalViewControllerAnimated:YES];

    NSLog (@"mail finished");
}

The application don't crash. After Cancel or Send button is presses Compose Window stays on the screen with buttons disabled. I can exit application pressing Home key.

I am able to open other Modal Views form TableView but not MailCompose.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uitableview