5

我的应用程序是基于横向的。我想在横向使用 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];

从上面可以看出,邮件撰写父视图是第三个加载的。在 info.plist 中,我这样做:

UIInterfaceOrientation = UIInterfaceOrientationLandscapeRight
4

5 回答 5

7

我们可以在 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
于 2011-01-05T12:01:11.220 回答
6

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

于 2009-11-19T14:51:14.187 回答
0

我有一个横向应用程序,显示 MFMailComposeViewController 似乎工作正常......

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

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

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

于 2009-07-09T02:58:41.273 回答
0

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

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

你需要这样的东西:

    [((AppDelegate *)[UIApplication sharedApplication]).window.rootViewController presentViewController:mailVC animated:YES];
于 2013-08-29T08:15:56.487 回答
-1

这个对我有用...

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

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
    {
        ......
    }
}    
于 2011-03-22T12:38:37.250 回答