模态视图控制器在iOS 5.1中不正确旋转,而不是在5.0中旋转

时间:2012-03-14 04:38:49

标签: ios modalviewcontroller ios5.1

我有一个横向的主视图控制器(整个应用程序是横向左/右)。

该主视图使用以下方式呈现模态视图:

ModalViewController *modalVC = [[ModalViewController alloc] init];
[modalVC setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:modalVC animated:YES];

在iOS 5.0 *中,这完全符合我的预期,主视图在横向中,模态视图以横向显示。

在iOS 5.1中,主视图立即向左旋转90º,然后模态视图也会旋转90°并进行裁剪。当模态视图被解除时,主视图会恢复正常且处于横向状态。

我已尝试过shouldAutorotateToInterfaceOrientation的各种突变,但它没有效果。我现在就这样离开了:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

我只是无法解决这个问题,直到我将iOS 5.1放在我的iPhone上并第一次运行应用程序之前就没有问题。

提前致谢!

*这是使用5.0和5.1 iPhone模拟器确认的

1 个答案:

答案 0 :(得分:-1)

确保在执行此操作之前显示模态视图控制器(不带动画):

[window makeKeyAndVisible]

所以请致电

[uiviewcontroller presentViewController:modalViewController animated:NO completion:nil];
[window makeKeyAndVisible];
相关问题