在横向上显示MFMailComposeViewController

问题描述:

我的应用程序是基于横向的。我想在横向上使用MFMailComposeViewController,但找不到任何关于方向的信息。在横向上,MFMailComposeViewController仅显示邮件撰写窗口的顶部,在横向时从左侧进入。基本上它覆盖了一半的景观屏幕。有没有办法让邮件撰写窗口出现在横向而不是纵向?在横向上显示MFMailComposeViewController

--- --- EDIT其中 我想载入邮件撰写的视图导出这样的:

//from first UIViewController 
[self presentModalViewController:secondView animated:YES]; 

//from secondView (a UIViewController), I load the info view, which is where the mail compose shows 
InfoController *infoController = [[InfoController alloc] initWithNibName:@"Info" bundle:[NSBundle mainBundle]]; 
[self.view addSubview:infoController.view]; 

根据上述内容,邮件撰写父视图是第三个加载。在Info.plist中,我这样做:

UIInterfaceOrientation = UIInterfaceOrientationLandscapeRight 

如果您在嵌套的UIViewController上显示MailViewController,请尝试在您的主UIViewController上显示它。这为我解决了这个问题。我刚把主控制器传给主控制器。

我有一个景观的应用程序,并呈现出MFMailComposeViewController似乎很好地工作......

我的应用程序切换到肖像模式有时会因为的UIImagePickerController 确实在横向模式下不工作,所以我用下面的代码在我看来,重新设立风景模式...

self.bounds = CGRectMake(0, 0, 480, 320); 
self.center = CGPointMake(160, 240); 
self.transform = CGAffineTransformMakeRotation(M_PI/2); 

的MFMailComposeViewController应该拿起这些价值观念,知道如何展示我自行宣布。

+0

我使用MFMailComposeViewController的委托在一个UIViewController:

你需要这样的事情。我必须使用self.view.bounds等。如果我在UIViewController的viewDidLoad中设置了它,它将加载我不想要的肖像。如果我在显示邮件撰写视图之前执行此操作,则会得到与OP中相同的结果。 – 4thSpace 2009-07-09 03:18:11

+0

在邮件撰写视图之前您展示了什么样的视图?你有没有告诉操作系统你处于横向模式,还是你正在做自己的绘图,只是让它横向? – 2009-07-10 15:14:37

+0

对不起。我已经编辑了OP来回应你的问题。请看一看。 – 4thSpace 2009-07-15 15:05:26

我们可以在Application Delegate类实现中添加以下代码来覆盖邮件编辑器视图控制器的自动旋转。

@interface MFMailComposeViewController (AutoRotation) 
// to stop auto rotation 
@end 

@implementation MFMailComposeViewController (AutoRotation) 
// stop auto rotation 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // should support all interface orientations. 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
@end 

这个工作对我来说...

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // return (YES); 
    return (interfaceOrientation==UIInterfaceOrientationLandscapeRight); 
} 

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) 
    { 
     ...... 
    } 
}  

尝试发送 “presentModalViewController:” 你的应用程序窗口RootViewController的(在AppDelegate中)。

我认为这适用于我,因为MFMailComposeViewController不能强制rootViewController方向,但可以强制rootViewController的navigationController推送的viewControllers的方向。

[((AppDelegate *)[UIApplication sharedApplication]).window.rootViewController presentViewController:mailVC animated:YES];