没有为MFMailComposeViewController调用didFinishWithResult

时间:2012-05-18 21:17:53

标签: iphone objective-c ios4 ios5

在buttonpress回调中:

 MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
    mailViewController.mailComposeDelegate = self;

    [self presentModalViewController:mailViewController animated:YES];

代表实施:

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
NSLog (@" Inside  MAIL COMPOSER CONTROLLER DELIGATE ");


// Remove the mail view
[self dismissModalViewControllerAnimated:YES];
}

当我按下MailComposerView中的取消按钮时,不会调用删除。我做错了什么?

2 个答案:

答案 0 :(得分:1)

  1. 将viewController设置为MFMailComposeViewControllerDelegate:

    @interface CurrentViewController : UIViewController <MFMailComposeViewControllerDelegate>
    
  2. 在实例化后立即设置mailComposer委托:

    MFMailComposeViewController * mailComposer = [[MFMailComposeViewController alloc]init];
    mailComposer.mailComposeDelegate = self;
    

答案 1 :(得分:0)

你真的让你的班级成为MFMailComposeViewControllerDelegate吗?

@interface MyViewController : UIViewController <MFMailComposeViewControllerDelegate>