在项目摘要中,“Supported Interface Orientations”都被选中,因为我的应用程序中有一个照片库 View ,可以随设备旋转。其他 View 仅为纵向 View 。目标设备是 iPhone,一切都在 iPhone 上表现良好。但是当它在我的 iPad 上以横向模式运行时,启动画面和 rootView 如下:
飞溅景观:
Root View 景观:
我期望的外观应该与 iPad 的纵向模式相同:
飞溅肖像:
Root View 纵向:
rootView是MyNavigationController
,部分相关代码如下:
MyNavigationController.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotate {
return NO;
}
最佳答案
请使用以下内容更正您的代码:
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
从 shouldAutorotate
返回 YES
似乎很奇怪。事实上,如果您返回 NO
,则根本不会调用 supportedInterfaceOrientations
,您的项目设置将起作用。您也可以删除 shouldAutorotate
,它应该可以正常工作。
When the user changes the device orientation, the system calls this method on the root view controller or the topmost presented view controller that fills the window. If the view controller supports the new orientation, the window and view controller are rotated to the new orientation. This method is only called if the view controller’s shouldAutorotate method returns YES.
关于ios - 在 iPad 中以横向模式启动 iPhone App,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15092013/