IOS 6定位 [英] IOS 6 Orientation

查看:142
本文介绍了IOS 6定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个项目并遇到问题。我的问题是我正在制作一个5.0及以上的项目,我的项目都是纵向视图但只有一个视图同时具有视图(横向和纵向)我正在使用NavigationController自定义类并在自定义导航类中检查这样的方向。 / p>

I am working on a project and facing a problem. My problem is that i am making a project for 5.0 and above, My project is all in portrait view but only one view has both view (Landscape and portrait) i am using NavigationController custom class and check Orientations like this in custom navigation class `

    - (NSUInteger)supportedInterfaceOrientations
  {
int interfaceOrientation = 0;

if (self.viewControllers.count > 0)
{
    id viewController;
    for (viewController in self.viewControllers)
    {
       if ([viewController isKindOfClass:([CalenderViewController class])])
        {
            interfaceOrientation = UIInterfaceOrientationMaskAll;
        }
        else
        {
            interfaceOrientation = UIInterfaceOrientationMaskPortrait;
        }
    }
}
return interfaceOrientation;
}` 

CalenderViewController是我的视图,支持两个视图
此代码有效当我弹出一个视图到CalenderViewController时,popview很好,这很好但是当我在CalenderViewController上推一个只有纵向视图的新视图控制器时,新的viewcontroller仍保持在横向状态,而它应该处于纵向模式。向前寻找解决方案谢谢

CalenderViewController is my view that supported both view this code works fine for popview when i pop a view to CalenderViewController, this works fine but when i push a new view controller on CalenderViewController that has only portrait view then the new viewcontroller remains in landscape, whereas it should be in portrait mode .Looking forward for a solution thanks

推荐答案

在这种情况下,你不应该返回 shouldAutorotate 。如果你这样做,甚至不会检查支持的方向,你的控制器将停留在最后使用的方向上。

In cases like this, you shouldn't return NO on shouldAutorotate. If you do that, supported orientations won't even be checked and your controller will be stuck on the last orientation used.

相反,只需返回 on shouldAutorotate 并指定 supportedInterfaceOrientations 中的单个方向(纵向),就像你已经do。

Instead, just return YES on shouldAutorotate and specifiy a single orientation (portrait) in supportedInterfaceOrientations, like you already do.

上返回 YES shouldAutorotate 不是仅适用于您希望控制器自由旋转到其他方向的情况。在弹出或推送不同的视图后,如果您可能需要控制器旋转回其唯一支持的方向,也应该使用它。

Returning YES on shouldAutorotate isn't meant only for when you want you controller to freely rotate to other orientations. It should also be used when you might need your controller to rotate back to its only supported orientation after popping or pushing a view that does differently.

这篇关于IOS 6定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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