按操作表中的取消按钮,关闭邮件控制器视图
我有四个部分的表格视图。 其中一个部分的单元格包含电子邮件地址。 当我点击那个单元格时,我打开邮件视图控制器。 现在,当我点击导航栏上的取消按钮时,会出现一个操作表,其中有三个按钮。 这三个按钮之一是取消按钮。 现在我想返回到表格视图,当我点击这个取消按钮的行动表。 我已经尝试了所有可能的方法,包括
-(void)mailComposeController:
(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
MFMailComposeViewController
委托的方法。
请帮助我。 这是我的代码:
if(indexPath.section == 2)
{
if([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailcontroller = [[MFMailComposeViewController alloc]init];
[mailcontroller.mailComposeDelegate self];
[mailcontroller setToRecipients:[[NSArray alloc]initWithObjects:record.contactemail, nil]];
[self presentViewController:mailcontroller animated:YES completion:nil];
}
}
-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissViewControllerAnimated:YES completion:nil];
}
首先将这两个代表添加到.h
文件中,就像波纹管一样。
@interface yourViewController : UIViewController<
MFMessageComposeViewControllerDelegate, MFMailComposeViewControllerDelegate>{
///your code..
}
并委托给自己像波纹管......
MFMailComposeViewController *mailcontroller = [[MFMailComposeViewController alloc]init];
mailcontroller.mailComposeDelegate = self;
并尝试我的这种方法...
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
if (result == MFMailComposeResultSent)
{
NSLog(@"nn Email Sent");
[AppDelegate showAlert:@"Email Sent"];
}
if([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)])
[self dismissViewControllerAnimated:YES completion:nil];
else
[self dismissModalViewControllerAnimated:YES];
// [self dismissViewControllerAnimated:YES completion:nil];
}
尝试这个
链接地址: http://www.djcxy.com/p/94543.html上一篇: dismiss mail controller view on pressing cancel button in action sheet
下一篇: Suppress "Save Draft" button in MFMailComposeViewController