【发布时间】:2014-08-19 19:11:02
【问题描述】:
我在使用 MFMailComposeViewController 时遇到了一个奇怪的问题。我过去一直在使用 MFMailComposeViewController 没有任何问题,但现在我无法弄清楚这次出了什么问题,因此我希望得到您的帮助。
在我的应用程序中,我有多个 UIViewController,其中名为 MainViewController 的一个是 ViewController 容器,我在其中实现了左侧滑动菜单。在 MainViewController 中,我还添加了 UINavigationController。 UINavigationController 被分配并随后添加到 MainViewController 中,如下所示:
[self addChildViewController:self.navigationController];
[self.centerView addSubview:self.navigationController.view];
[self.navigationController didMoveToParentViewController:self];
上面的工作非常好,我可以使用导航控制器来推送和弹出其他 UIViewControllers。 在左侧菜单中,我有不同的按钮,其中一个名为“关于”。按下时会执行以下代码:
NSArray *array = [NSArray arrayWithObject:[AboutViewController sharedViewController]];
[self.navigationController setViewControllers:array animated:NO];
在 AboutViewController 中,我得到了一些按钮,其中一个是“发送反馈”。 “发送反馈”按钮执行以下代码:
if([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObjects:[NSString stringWithFormat:@"feedback@test.com"], nil];
[mailer setToRecipients:toRecipients];
[mailer setSubject:[NSString stringWithFormat:@"Feedback"]];
[self presentViewController:mailer animated:YES completion:nil];
}
这也有效。 AboutViewController 实现了 MFMailComposeViewControllerDelegate 及其方法:
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
switch (result) {
case MFMailComposeResultCancelled:
//NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued.");
break;
case MFMailComposeResultSaved:
//NSLog(@"Mail saved: you saved the email message in the drafts folder.");
break;
case MFMailComposeResultSent:
//NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send.");
break;
case MFMailComposeResultFailed:
//NSLog(@"Mail failed: the email message was not saved or queued, possibly due to an error.");
break;
default:
//NSLog(@"Mail not sent.");
break;
}
// Remove the mail view
[self dismissViewControllerAnimated:YES completion:nil];
}
而这里让我头疼。我打电话给
[self dismissViewControllerAnimated:YES completion:nil];
就像我在以前的应用程序中所做的那样,它可以正常工作。但在这种情况下,MFMailComposeViewController 不会被解除,并且“取消”和“发送”按钮变为非活动状态。我试图在关闭完成块中实现一个 NSLog,但它从未被调用。
我搜索了几个小时,但找不到解决此问题的方法。我希望你能帮我解决这个奇怪的问题。如果您需要更多信息,请询问。
提前致谢。 - 塞巴斯蒂安
【问题讨论】:
-
您的子视图控制器遇到了问题
-
您必须调整子视图的大小
-
我也有同样的问题,我解决了
-
您能说得更具体一点吗?在导航控制器的分配中我做了以下操作:
self.navigationController = [[UINavigationController alloc] init]; [self.navigationController setNavigationBarHidden:YES]; self.navigationController.view.frame = CGRectMake(0, 44, 320, [Utilities screenHeight] - 44); self.navigationController.delegate = self; self.navigationController.view.backgroundColor = [UIColor clearColor]; self.navigationController.navigationBar.translucent = NO; -
你是怎么解决的?
标签: ios objective-c iphone email uiviewcontroller