我在 iOS 4.3 下的 iPad 上构建了一个仅支持横向的应用程序,尽管该错误也存在于 iOS 4.2 下。
在应用程序的几个地方,我将 UIViewController
显示为模态视图。所有这些都使用这种模式显示:
viewController.modalPresentationStyle = UIModalPresentationFormSheet;
viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:viewController animated:YES];
在大多数地方,它们都按预期工作 - 模态表单从屏幕底部向上滑入。
但是,在两种情况下,模态表单是从屏幕左下方滑入的。表单几乎一直向右滑动,表单底部看不到。如果您聚焦文本字段并显示屏幕键盘,则表单将移动到屏幕顶部中央您期望的位置。
我不认为 XIB 的模拟指标会影响它们的行为,但我已经为它们设置了方向(包括调用 UIViewController
self
和模态视图 Controller viewController
) 到 Landscape.
知道为什么这两个模态表单的行为与其他表单不同吗?
最佳答案
我想在这里你不能在 shouldAutorotate 函数中返回横向,所以如果你想以横向左/右 View 查看,请使用此代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight||interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
// return YES;
}
试试这个可能对你有帮助..
关于ipad - 为什么 [UIViewController presentModalViewController :animated:] transitioning the modal view in from the left?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5200349/