MFMailComposeViewController:取消时退出

时间:2010-08-16 15:58:32

标签: iphone email

我有以下代码在应用程序中向用户显示电子邮件:

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self; 
[picker setSubject:@"Subject"];
NSString* link = [NSString stringWithFormat:@"<a href='%@'>Report</a>",link];
[picker setMessageBody:link isHTML:YES];
picker.navigationBar.barStyle = UIBarStyleDefault; 
[self presentModalViewController:picker animated:YES];
[picker release];

和所有:

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{ 
    [self dismissModalViewControllerAnimated:YES];
}

一切正常,期待我希望取消跳过删除草稿/保存草稿/取消阶段并基本选择删除草稿(不向用户呈现) 可以这样做吗? 谢谢

1 个答案:

答案 0 :(得分:1)

- (void)mailComposeController:(MFMailComposeViewController *) controller didFinishWithResult:(MFMailComposeResult) result error:(NSError *)error
    {
        switch (result) {
            case MFMailComposeResultCancelled:
                break;

            case MFMailComposeResultSaved:
                break;

            case MFMailComposeResultSent:
                break;

            case MFMailComposeResultFailed:
                break;

            default:
                break;
        }

        //Dismiss the mailViewController.
        [self dismissModalViewControllerAnimated:YES];
    }

这是你在找什么?然后,您可以单独处理每个错误或完成!