Mail composer上的DismissModaViewController无法正常工作

时间:2011-06-25 14:29:20

标签: mfmailcomposeviewcontroller

当我完成屏幕截图并尝试在应用中通过电子邮件发送屏幕截图时,我遇到了问题。通常情况下,它在发送文本时效果很好,但一旦发送屏幕截图,无论是取消还是发送电子邮件,屏幕都不会消失。我可以知道这有什么问题吗?

这是我的代码。非常感谢你。

- (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];
}

1 个答案:

答案 0 :(得分:0)

您需要实施的委托方法是mailComposeController:didFinishWithResult:error:,而不是mailComposeController:。有关详细信息,请参阅the documentation