Mail composer上的DismissModaViewController不起作用

问题描述

| 完成截图并尝试通过电子邮件将截图发送到应用程序时出现问题。通常,在发送文本时它可以完美运行,但是一旦发送屏幕截图,无论取消还是发送电子邮件,屏幕都不会消失。我可以知道这是什么问题吗? 这是我的代码。非常感谢你。
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

        if (buttonIndex == 0) {

        UIGraphicsBeginImageContext(self.view.frame.size);
        [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage * image = UIGraphicsGetimageFromCurrentimageContext();
        UIGraphicsEndImageContext();

        NSData * imageData = UIImageJPEGRepresentation(image,1.0);

        if ( [MFMailComposeViewController canSendMail] ) {
            MFMailComposeViewController * mailComposer = [[[MFMailComposeViewController alloc] init] autorelease];
            mailComposer.delegate = self;
            [mailComposer addAttachmentData:imageData mimeType:@\"image/jpeg\" fileName:@\"attachment.jpg\"];

            /* Configure other settings */

            [self presentModalViewController:mailComposer animated:YES];
        }
    }
}
- (void)mailComposeController:(MFMailComposeViewController*)controller{
    [self dismissModalViewControllerAnimated:YES];
}
    

解决方法

        您需要实现的委托方法是
mailComposeController:didFinishWithResult:error:
,而不是
mailComposeController:
。有关详细信息,请参见文档。