MFMailComposeViewController不会在iOS 6
问题描述:
解雇在iOS 6中所提出的MFMailComposeViewController
不会解散,如果用户试图发送第二封邮件......MFMailComposeViewController不会在iOS 6
一切完美的作品首次面世,并发送电子邮件。但是,如果再次选择电子邮件选项,MFMailComposeViewController
不会取消取消。
这里是我是如何实现它:
- (IBAction)buttonEmailClick:(id)sender {
if (![MFMailComposeViewController canSendMail]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Can't send" message:@"This device is unable to send emails." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
return;
}
NSDictionary *contactsInfo = [self contactsInfoFromPlistNamed:kConfigPlistName];
[mailComposeViewController setToRecipients:[NSArray arrayWithObject:[contactsInfo objectForKey:@"email"]]];
//[mailComposeViewController setSubject:kEmailDefaultSubject];
//[mailComposeViewController setMessageBody:text isHTML:NO];
[self presentModalViewController:mailComposeViewController animated:YES];
}
,然后这样的:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
UIAlertView *alert = nil;
if (result == MFMailComposeResultSent) {
alert = [[UIAlertView alloc] initWithTitle:@"Sent" message:@"Your email was sent." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
}
else if (result == MFMailComposeResultFailed) {
alert = [[UIAlertView alloc] initWithTitle:@"Failed" message:@"An error occured and your email was not sent." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
}
[alert show];
[self dismissModalViewControllerAnimated:YES];
}
它工作正常,在iOS 5中,但不是在iOS的6我曾尝试与非不赞成的方法代替iOS 6,但它不起作用。
答
您是否尝试过在每次发送邮件时都创建一个新的MFMailComposeViewController?我不确定你是否应该重复使用它。
答
你可以试试这个:
MFMailComposeViewController * composer = [[MFMailComposeViewController alloc] init];
composer.delegate = self;
- (空)mailComposeController:didFinishWithResult:错误:如果您分配类委托
应该叫我认为这就是问题所在!一旦电子邮件发送并且用户被带回到呈现视图控制器,是否有方法创建新的MFMailComposeViewController?我非常感谢快速回复和帮助。 – user2175392 2013-03-15 20:19:37
是的,我的建议是在调用'setToRecipients'之前放置'mailComposeViewController = [[MFMailComposeViewController alloc] init];'。 – 2013-03-15 20:21:11
太棒了。谢谢!我会尝试第二次回到Mac。 – user2175392 2013-03-15 20:40:55