我在关闭我提出的电子邮件时遇到困难。
电子邮件打开得很好,但一旦打开它就不会关闭,因为 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];
}
后来在课堂上我有这个代码来处理关闭(但它永远不会被调用):
-(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>
Thanks
Iphaaw
您设置的委托错误,委托属性在MFMailComposeViewController
被称为mailComposeDelegate,所以它应该是:
mailer.mailComposeDelegate = self;
我看到的另一个可能的错误是调用dismissModalViewControllerAnimated:
on mailer
- 您应该将此消息发送给呈现邮件界面的视图控制器 -self
在这种情况下:
[self dismissModalViewControllerAnimated:YES];
我写了“可能的错误”,因为无论如何,如果 iOS 通过响应者链路由消息,它实际上可能会起作用 - 文档说它应该发送给演示者。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)