ios - 在 iPad 中以横向模式启动 iPhone App

标签 ios ipad orientation splash-screen

在项目摘要中,“Supported Interface Orientations”都被选中,因为我的应用程序中有一个照片库 View ,可以随设备旋转。其他 View 仅为纵向 View 。目标设备是 iPhone,一切都在 iPhone 上表现良好。但是当它在我的 iPad 上以横向模式运行时,启动画面和 rootView 如下:

飞溅景观: enter image description here

Root View 景观: enter image description here

我期望的外观应该与 iPad 的纵向模式相同:

飞溅肖像: enter image description here

Root View 纵向: enter image description here

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,它应该可以正常工作。

Reference :

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/

相关文章:

ios - xcode 6.1 启动屏幕启动图像空白

objective-c - 核心数据需要帮助(初学者)

ios - 自定义输入 View : how to prevent them from fading during orientation change?

javascript - 强制水平负载

php - 通过移动应用程序为二维码的值添加前缀

ios - 适合开放式键盘 Swift

iphone - 在 Pinterest 上分享视频

UIImagePickerController 返回错误的图像方向

ios - NSArray 中 NSNumbers 的频率

iphone - 动画 UIPickerView 在横向模式下不旋转