iphone - iOS 6 的多个 UIInterfaceOrientations 应用程序

标签 iphone ios ios6 uiinterfaceorientation

我在尝试从 iOS 6 设置新的 UIInterfaceOrientations 时遇到了麻烦。

恢复我的应用:

  • 我的应用有很多 View ;
  • 几乎每个 View 都应以纵向显示;
  • 我的 2 个 View (使用 MPMoviePlayerViewController 播放视频的 View )应该向左、向右和纵向旋转。

我最初的想法是将应用支持的方向设置为纵向,然后更改(不知道如何)从视频播放器 View 支持的方向。

处理此问题的最佳方法是什么?

提前致谢!

最佳答案

通过将 Supported Interface Orientations 设置为我需要的所有内容(纵向、左右横向)并添加 UINavigationController 的一个 Category 解决了这个问题。

我将类别添加到任何我想保持纵向模式的 UINavigationController 并将 iOS 6 旋转视为 this post :

@implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

@end

实现后我仍然有一些问题,因为代码是这样的:

[self.window.rootViewController presentModalViewController:controller animated:NO]; 

而不是这个:

[self.navigationController pushViewController:controller animated:NO];

通过上述更改,我能够将整个应用程序保持在纵向模式并让视频播放器 View 保持旋转,因为它们的方法(shouldRotate 和 supportedInterfaceOrientations)没有被覆盖。

关于iphone - iOS 6 的多个 UIInterfaceOrientations 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12610132/

相关文章:

iphone - 创建 plist 文件 iOS 不工作

ios - 由于失去连接而丢失消息 xmpp

ios - 如何在 UITableview 中创建一个包含 n 行的 UITextField

ios - 如果从详细 View Controller 导航到新 View Controller ,如何隐藏主视图

ios - 将 iOS 6 SDK 导入 Snow Leopard 上的 Xcode 4.2

iphone - 将换行符替换为 <br> 以在 UIWebView 中使用

iphone - 核心数据最佳实践

objective-c - 子类化 CCSprite 的优势

iphone - MkAnnotation 掉落动画 iOS 6

objective-c - 在应用程序构建目标 <= iOS 6 中使用 hidesBottomBarWhenPushed 时,iOS 7 上出现奇怪的动画