无法关闭MFMailComposeViewController,委托未调用 [英] Unable to dismiss MFMailComposeViewController, delegate not called
本文介绍了无法关闭MFMailComposeViewController,委托未调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从 UITableViewController
调用 MFMailComposeViewController
。
问题是当我在邮件撰写窗口中选择取消或发送按钮时,从不调用委托方法:
I am calling MFMailComposeViewController
from a UITableViewController
.
Problem is the delegate method is never called when I select Cancel or Send button in Mail compose window:
mailComposeController:(MFMailComposeViewController*)controllerdidFinishWithResult
这是表视图类:
@implementation DetailsTableViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section==0 && indexPath.row==4) {
//SEND MAIL
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
if ([MFMailComposeViewController canSendMail]) {
[controller setSubject:[NSString stringWithFormat:@"Ref %@",[item objectForKey:@"reference"]]];
[controller setMessageBody:@" " isHTML:NO];
[controller setToRecipients:[NSArray arrayWithObject:[item objectForKey:@"email"]]];
[self presentModalViewController:controller animated:YES];
}
[controller release];
}
}
- (void)mailComposeController:(MFMailComposeViewController*)controllerdidFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
// NEVER REACHES THIS PLACE
[self dismissModalViewControllerAnimated:YES];
NSLog (@"mail finished");
}
应用程序不会崩溃。按下取消或发送按钮后,构建窗口将停留在屏幕上并禁用按钮。我可以按Home键退出应用程序。
The application doesn't crash. After the Cancel or Send button is pressed, the Compose Window stays on the screen with buttons disabled. I can exit application pressing Home key.
我可以打开TableView的其他模态视图而不是MailCompose。
I am able to open other Modal Views form TableView but not MailCompose.
推荐答案
确保使用
controller.mailComposeDelegate = self;
而不是
controller.delegate = self;
这篇关于无法关闭MFMailComposeViewController,委托未调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文