4

我正在构建一个仅支持 iOS 4.3 下 iPad 上的横向方向的应用程序,尽管该错误也存在于 iOS 4.2 下。

在应用程序的几个地方,我将UIViewControllers 显示为模态视图。所有这些都使用这种模式显示:

viewController.modalPresentationStyle = UIModalPresentationFormSheet;
viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:viewController animated:YES];

在大多数地方,它们按预期工作——模态表单从屏幕底部向上滑入。

但是,在两种情况下,模态表单从屏幕的左下方滑入。表单几乎一直向右滑动,表单的底部不可见。如果您聚焦文本字段并显示屏幕键盘,表单将移动到您期望的屏幕顶部中心。

我不认为 XIB 的模拟指标会影响它们的行为,但我已将它们(调用UIViewController self和模态视图控制器viewController)的方向设置为横向。

任何想法为什么这两个模态表单的行为与其他表单不同?

4

2 回答 2

0

我认为你在这里应该在 shouldAutorotate 函数中返回横向,所以如果你想以横向左/右查看,请使用此代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight||interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    // return YES;
}

试试这个可能对你有帮助..

于 2012-07-21T07:16:59.227 回答
0

确保您是否在 NavigationController 中嵌入了 viewController,并且 navController shouldAutotorate 也设置为 Landscape

于 2012-07-21T08:47:36.927 回答