iOS 6的多个UIInterfaceOrientations应用程序 [英] Multiple UIInterfaceOrientations app with iOS 6

查看:80
本文介绍了iOS 6的多个UIInterfaceOrientations应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正忙着尝试从iOS 6设置新的UIInterfaceOrientations。

I'm having a bad time trying to set the new UIInterfaceOrientations from iOS 6.

恢复我的应用:


  • 我的应用程序有很多视图;

  • 几乎每个视图都应显示在纵向方向上;

  • 我的2个视图(使用 MPMoviePlayerViewController 播放视频的视图)应该旋转到左,右和纵向。

  • My app have a bunch of views;
  • Almost every view should be shown on Portrait orientation;
  • 2 of my views (the ones that play videos with MPMoviePlayerViewController) should rotate to left, right and portrait orientations.

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

My original idea was to set the app supported orientation to Portrait and than change (don't know how) the supported orientation from the video player views.

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

What would be the best way to deal with this?

提前谢谢你!

推荐答案

通过将支持的界面方向设置为我需要的所有内容(纵向,横向左右)并添加一个类别 of UINavigationController

The problem was solved using by setting the Supported Interface Orientations to all I need (Portrait, Landscape right and left) and adding one Category of UINavigationController.

我添加了类别任何出现的 UINavigationController 我希望保持在纵向模式并处理iOS 6轮换,如这篇文章

I added the Category to any occurrence of UINavigationController that I want to stay on Portrait mode and treated the iOS 6 rotation like this post:

@implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

@end

有了这个实现我还有一些问题,因为代码是这样的:

With this implemented I still have some problems because the code was like this:

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

而不是:

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

通过上述更改,我可以将整个应用程序保留在纵向模式下并让视频播放器观看因为他们的方法(shouldRotate和supportedInterfaceOrientations)没有被覆盖而继续旋转。

With the above changes I was able to keep the entire app on Portrait Mode and let the video player views to keep rotating because their methods (shouldRotate and supportedInterfaceOrientations) weren't overridden.

这篇关于iOS 6的多个UIInterfaceOrientations应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆