MFMailComposeViewController 不解雇
我有在 didSelectRowAtIndexPath 中调用的以下代码。问题是,当我点击取消按钮时,它提示保存草稿或放弃。但是当我单击其中任何一个时,视图都不会消失。我在 iOS 5 之前的应用程序中使用了相同的代码,并且效果很好。有什么想法吗?我在界面中有 MFMailComposeViewController 委托协议。
if (indexPath.row == 0)
{
if([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Support"];
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
[picker setToRecipients:toRecipients];
NSString *emailBody = text;
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
}
}
I have the following code that gets called in didSelectRowAtIndexPath. The issue is, when I click the cancel button, it prompts for save draft or discard. But when I click either, the view does not dismiss. I've used the same code in a pre iOS 5 app and it dismissed fine. Any ideas? I have the MFMailComposeViewController delegate protocol in the interface.
if (indexPath.row == 0)
{
if([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Support"];
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
[picker setToRecipients:toRecipients];
NSString *emailBody = text;
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用:
从 IOS 6.0 开始已弃用:
将此方法添加到您的类中:
玩得开心
Use:
DEPRECATED FROM IOS 6.0:
Add this method to your class:
Have fun
可能存在几个问题:
未在 .h 中添加协议实现
不在.m中添加相关函数:
我的错误是没有设置正确的委托,但我修复了它:),现在它对我有用:
There could be several problems:
Not adding protocol implemantation in the .h
Not adding the relevant function in .m:
My error was not setting the correct delegate, but I fixed it :) and now it works for me:
“dismissModalViewControllerAnimated:”在 iOS 6.0 中已弃用
iOS 7 使用:
“dismissViewControllerAnimated:completion:”
"dismissModalViewControllerAnimated:"is deprecated in iOS 6.0
iOS 7 use:
"dismissViewControllerAnimated:completion:"
我在这里更详细地描述了该问题以及解决该问题的方法:https://stackoverflow。 com/a/13576408/691660
我不确定旅达是否抓住了问题的核心。无论您是否指定委托都没有区别,这在模态+模态 MFMailComposeViewController 实例的情况下不起作用。
I've described the problem and the way it can be solved more detailed here: https://stackoverflow.com/a/13576408/691660
I am not sure if Luda caught the core of the problem. No difference whether you specify the delegate or not, that does not work in case of modal+modal MFMailComposeViewController instance.
Swift 实现:
确保您的
MFMailComposeViewController
协议和委托在每次执行其函数时都被调用。这解决了
MFMailComposeViewController
不被解雇的问题。Swift Implementation:
Make sure your
MFMailComposeViewController
protocol and delegate is being called every time its function being executed.This solves the issue of
MFMailComposeViewController
not being dismissed.