MFMailComposeViewController未在横向模式下打开。但在肖像模式下工作

问题描述:

花了一些时间看堆栈溢出的类似问题后,不幸的是没有人似乎解决了我的问题。MFMailComposeViewController未在横向模式下打开。但在肖像模式下工作

我使用的是UIActionSheet,当用户点击的动作片发送电子邮件,下面的代码被称为:

if ([MFMailComposeViewController canSendMail]){ 
       NSString *emailTitle = @"bla bla bla"; 
       // Email Content 
       NSString *messageBody = @"bla bla bla"; 
       // To address 
       NSArray *toRecipents = [NSArray arrayWithObject:@"[email protected]"]; 

       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的

任何方位

再次编辑 张望了一下打经过,如果我的代码分配给一个按钮,它工作得很好,只有从动作片选择电子邮件时,这方面的问题目前

+0

可能重复troller不会开始在横向模式](http://*.com/questions/3772016/modal-view-controller-wont-start-in-landscape-mode) – LoVo 2015-03-13 10:41:48

+0

您是否尝试使用根视图控制器来呈现它? – Dennis 2015-03-13 10:44:42

+0

@丹尼斯我试过这个使用但没有区别'[self.view.window.rootViewController presentViewController:mc animated:YES completion:NULL];' – Manesh 2015-03-13 10:49:37

找到了答案,这是它:

dispatch_async(dispatch_get_main_queue(),^{ 
    // INSERT EMAIL CODE HERE 
}); 
[模式的看法精读的