Cocoa touch 在横向视图中显示MFMailComposeViewController

Cocoa touch 在横向视图中显示MFMailComposeViewController,cocoa-touch,iphone-sdk-3.0,uiviewcontroller,Cocoa Touch,Iphone Sdk 3.0,Uiviewcontroller,我的应用程序是基于风景的。我想在横向中使用MFMailComposeViewController,但找不到任何关于方向的通知。在横向中,MFMailComposeViewController在横向中仅显示邮件撰写窗口的顶部,从左侧进入。基本上它覆盖了一半的横向屏幕。有没有办法让邮件撰写窗口以横向而非纵向显示 ---编辑--- 我要在其中加载邮件撰写的视图派生如下: //from first UIViewController [self presentModalViewController:sec

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

---编辑--- 我要在其中加载邮件撰写的视图派生如下:

//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];
    [((AppDelegate *)[UIApplication sharedApplication]).window.rootViewController presentViewController:mailVC animated:YES];
从上面可以看出,mail compose父视图是加载的第三个视图。在info.plist中,我执行以下操作:

UIInterfaceOrientation = UIInterfaceOrientationLandscapeRight

我有一个横向应用程序,显示MFMailComposeViewController似乎很好

我的应用程序有时必须切换到纵向模式,因为UIImagePickerController在横向模式下不工作,所以我在视图中使用以下代码来重新设置横向模式

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

MFMailComposeViewController应该选择这些值并知道如何显示自己。

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

我们可以在应用程序委托类实现中添加以下代码,以覆盖mail composer视图控制器的自动旋转

@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推送的ViewController定向

你需要这样的东西:

//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];
    [((AppDelegate *)[UIApplication sharedApplication]).window.rootViewController presentViewController:mailVC animated:YES];

我正在UIViewController中使用MFMailComposeViewController的委托。我必须使用self.view.bounds等等。如果我在UIViewController的viewDidLoad中设置了您想要的内容,它将加载纵向,这是我不想要的。如果我在“邮件撰写”视图显示之前执行此操作,则会得到与OP中相同的结果。在“邮件撰写”视图之前显示的是哪种视图?你有没有告诉操作系统你处于横向模式,或者你正在做你自己的画,只是让它横向?抱歉耽搁了。为了回答你的问题,我编辑了这篇文章。请看一看。为我工作!谢谢我也明白了原因:在我们的例子中,主视图控制器是处理旋转的控制器,也是唯一一个改变其旋转的控制器。邮件生成器根据viewcontroller的rotation@Dimitris,请你把电话号码寄给我好吗sample@Ravan我不知道在哪里可以找到它,我也不认为5年前的代码在iOS开发中会有用。。。我相信从那以后事情一定发生了很大的变化。太好了!它工作得非常完美(唯一的事情是在IOS 6中,我使用-shouldAutorotate和-supportedInterfaceOrientations方法代替-shouldAutorotateToInterfaceOrientation:)。谢谢