我使用UINavigationController和UITabBarController创建了一个应用程序。我尝试使用" MFMailComposeViewController"发送邮件。但得到ab错误,应用程序被粉碎。 我的代码:
(IBAction)SendMail:(UIButton *)sender { if([MFMailComposeViewController canSendMail]){ MFMailComposeViewController * mailCont = [[MFMailComposeViewController alloc] init]; mailCont.mailComposeDelegate = self;
[mailCont setSubject:@"yo!"];
[mailCont setToRecipients:[NSArray arrayWithObject:@"joel@stackoverflow.com"]];
[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];
我做了导入:#import
答案 0 :(得分:0)
尝试
mailComposer.mailComposeDelegate = self;
而不是
mailComposer.delegate = self;