当我试图发送邮件时,MFMailComposeViewController粉碎了。我正在使用UINavigationController和UITabBarController

时间:2014-11-22 00:08:55

标签: xcode ios7 uinavigationcontroller uitabbarcontroller mfmailcomposeviewcontroller

我使用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

导入并使用MFMailComposeViewControllerDelegate。

1 个答案:

答案 0 :(得分:0)

尝试

mailComposer.mailComposeDelegate = self;

而不是

mailComposer.delegate = self;