【发布时间】:2015-03-13 10:35:58
【问题描述】:
在花了一些时间查看有关堆栈溢出的类似问题后,不幸的是,似乎没有一个可以解决我的问题。
我使用的是UIActionSheet,当用户点击操作表上的发送电子邮件时,会调用以下代码:
if ([MFMailComposeViewController canSendMail]){
NSString *emailTitle = @"bla bla bla";
// Email Content
NSString *messageBody = @"bla bla bla";
// To address
NSArray *toRecipents = [NSArray arrayWithObject:@"test@test.com"];
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
[mc setToRecipients:toRecipents];
[self.view.window.rootViewController presentViewController:mc animated:YES completion:NULL];
NSLog(@"email view opened");
}
else{
UIAlertView *anAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"No mail account setup on device" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
[anAlert addButtonWithTitle:@"Cancel"];
[anAlert show];
}
MFMailComposeViewController 在我的 iPhone 上以纵向模式打开,但在 iPad 上以横向模式打开应用程序时,没有任何反应。没有视图弹出,什么都没有。
它在NSLog 中显示“已打开电子邮件视图”,但仅此而已。
想法?
编辑该应用仅在 iPhone 上为纵向,在 iPad 上为任意方向
再次编辑 在玩了一会儿之后,如果我将代码分配给一个按钮,它工作正常,只有从操作表中选择电子邮件时才会出现这个问题
【问题讨论】:
-
你试过用根视图控制器来呈现它吗?
-
@Dennis 我已经尝试过使用但没有任何区别
[self.view.window.rootViewController presentViewController:mc animated:YES completion:NULL]; -
我也看过那些,但仍然没有解决对不起@LoVo
标签: ios objective-c xcode uiactionsheet mfmailcomposeviewcontroller