旋转在 iOS6 上表现不同 [英] Rotation behaving differently on iOS6

查看:21
本文介绍了旋转在 iOS6 上表现不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个基于标签的应用程序.无需在横向模式下使用任何东西,只需要几个视图即可.它在 iOS5 上运行良好,我对结果非常满意.然而,在 iOS6 中,没有任何问题,它现在会旋转所有视图,结果并不好.

I did an App which is tab-based. Nothing needs to be on landscape mode but a couple of views. It worked OK on iOS5 and I was pretty happy with the result. However with iOS6 and without messing with anything, it now rotates all the views and the consequences are not nice.

因为它是一个基于选项卡的应用程序,所以我在横向中需要的几个视图是 modalViews.这样我就不会弄乱标签栏,我只需要在构建选项的支持的方向"设置中选择纵向并设置:

Because its a tab-based app, the couple of view I need in landscape are modalViews. That way I didn't mess with the tabbar and I had only to chose portrait in the "Supported Orientations" setting on build options and set:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

关于我想要的风景.

现在在 iOS6 中,这个视图也处于纵向模式,无论如何,即使我旋转设备,它们也不会显示横向模式.同样,如果我允许支持的方向"上的所有方向,它们都会旋转,无论我在上面的方法上放什么.

Now with iOS6 this views are also on portrait mode, no matter what and they do not show the landscape mode even if I rotate the device. Likewise, if I allow all the orientations on the "Supported orientations", they all rotate, no matter what I put on the method above.

在所有视图中,我都没有选中故事板上的使用自动布局"框.

On all the views I haven't check the box "Use Autolayout" on storyboards.

这里有什么帮助吗?

*编辑**现在我看到了,我在设备上的应用程序运行良好.我已经安装了促销代码,而不是来自 Xcode,只是为了看看我的客户是否有问题.幸运的是他们不是.问题仍然存在.

*EDIT** Now that I see it, the App I have on the device works fine. I've installed with a promo code, not from Xcode, only to see whether my customers are having problems or not. Fortunatelly they are not. The problem remains though.

推荐答案

我找到的有关此问题的文档中最重要的部分是:

The most important part of the documentation I found for this issue is:

当用户改变设备方向时,系统调用这个根视图控制器或最顶层呈现的视图上的方法填充窗口的控制器

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

为了让我的应用在 iOS 6 中完全自动旋转,我必须执行以下操作:

To make my app fully working for autorotation in iOS 6, I had to do the following:

1) 我创建了一个新的 UINavigationController 子类,并添加了 shouldAutorotate 和 supportedInterfaceOrientation 方法:

1) I created a new subclass of UINavigationController, and added shouldAutorotate and supportedInterfaceOrientation methods:

// MyNavigationController.h:
#import <UIKit/UIKit.h>

@interface MyNavigationController : UINavigationController

@end

// MyNavigationController.m:
#import "MyNavigationController.h"
@implementation MyNavigationController
...
- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}
...
@end

2) 在 AppDelegate 中,我确实使用了我的新子类来显示我的根 ViewController(它是 introScreenViewController,一个 UIViewController 子类)并确实设置了 self.window.rootViewController,所以看起来:

2) In the AppDelegate, I did use my new subclass to show my root ViewController (it is introScreenViewController, a UIViewController subclass) and did set the self.window.rootViewController, so it looks that:

    nvc = [[MyNavigationController alloc] initWithRootViewController:introScreenViewController];
    nvc.navigationBarHidden = YES;
    self.window.rootViewController = nvc;
    [window addSubview:nvc.view];
    [window makeKeyAndVisible];

这篇关于旋转在 iOS6 上表现不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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