michaellindahl
michaellindahl

Reputation: 2052

In App Email View doesn't close - iPhone OS 4

I am having difficulties adding the ability for a user to send a support email to myself (the maker of said app). I have gotten it work almost perfectly however the view doesn't close when you click cancel, or when you click send. Thanks for the help!

Here is the code:

 MFMailComposeViewController *mail = [[[MFMailComposeViewController alloc] init] autorelease];


        mail.mailComposeDelegate = self;

        [mail setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
        [mail setSubject:@"Fraction Calculator Lite Support"];    

        [self presentModalViewController:mail animated:YES];

Upvotes: 1

Views: 234

Answers (2)

ageektrapped
ageektrapped

Reputation: 14552

You're setting self to be the MFMailComposeViewController's delegate. In mailComposeController:didFinishWithResult:error: be sure to call

[self dismissModalViewControllerAnimated:YES];

like so:

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
    [self dismissModalViewControllerAnimated:YES];
}

Upvotes: 3

thelaws
thelaws

Reputation: 8001

You need to implement the delegate method from MFMailComposeViewControllerDelegate.

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
    [self dismissModalViewControllerAnimated:YES];
}

Upvotes: 0

Related Questions