0
votes

I created an application using both UINavigationController and UITabBarController. I'm trying to send mail using "MFMailComposeViewController" but get ab error and the application is crushed. My code:

  • (IBAction)SendMail:(UIButton *)sender { if([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailCont = [[MFMailComposeViewController alloc] init]; mailCont.mailComposeDelegate = self;

    [mailCont setSubject:@"yo!"];
    [mailCont setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
    [mailCont setMessageBody:@"Don't ever want to give you up" isHTML:NO];
    
    [self presentModalViewController:mailCont animated:YES];
    

    }

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

and i did import: #import

import and use the MFMailComposeViewControllerDelegate.

1

1 Answers

0
votes

Try

mailComposer.mailComposeDelegate = self;

instead of

mailComposer.delegate = self;