Reputation: 51
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
Upvotes: 0
Views: 112
Reputation: 6888
Try
mailComposer.mailComposeDelegate = self;
instead of
mailComposer.delegate = self;
Upvotes: 0