gpt4 book ai didi

iPhone:如何关闭 MFMailComposeViewController?

转载 作者:太空狗 更新时间:2023-10-30 03:58:34 25 4
gpt4 key购买 nike

我无法关闭我提出的电子邮件。

电子邮件打开得很好,但一旦打开它就不会关闭,因为 mailComposeController:mailer didFinishWithResult:result error:error 处理程序永远不会被调用。

据我所知,我已准备好执行此操作的所有条件。

有人知道我可以看什么吗?

这是我提出电子邮件的方式:

-(IBAction)emailButtonPressed 
{

NSString *text = @"我的邮件正文";

 MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.delegate = self;

[mailer setSubject:@"Note"];
[mailer setMessageBody:text isHTML:NO];
[self presentModalViewController:mailer animated:YES];
[mailer release];
}

后来在类(class)中我有这段代码来处理关闭(但它从未被调用):

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

我的头文件定义为:

#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>

@interface myViewController : UIViewController <UIActionSheetDelegate, UIAlertViewDelegate, MFMailComposeViewControllerDelegate, UINavigationControllerDelegate>

谢谢

怡保

最佳答案

您设置的委托(delegate)有误,MFMailComposeViewController 中的委托(delegate)属性称为 mailComposeDelegate,因此它应该是:

mailer.mailComposeDelegate = self;

我看到的另一个可能的错误是在 mailer 上调用 dismissModalViewControllerAnimated: - 您应该将此消息发送给显示邮件界面的 View Controller - self 在这种情况下:

[self dismissModalViewControllerAnimated:YES];

我写了“可能的错误”,因为如果 iOS 通过响应者链路由消息,它可能实际上会起作用,无论如何 - 文档说它应该发送给演示者。

关于iPhone:如何关闭 MFMailComposeViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4104199/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com