rs设置不同的supportedInterfaceOrienta

rs设置不同的supportedInterfaceOrienta

本文介绍了为不同的UIViewControllers设置不同的supportedInterfaceOrientations的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,正如问题所示,我使用以下代码为viewcontroller设置userinterfaceOrientation。

So, as by the question, I use the following code to set userinterfaceOrientation for the viewcontroller.

- (BOOL) shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

我尝试设置 UIInterfaceOrientationMaskAll 另一个viewController。

I tried setting UIInterfaceOrientationMaskAll for another viewController.

之前,我检查了info-plist中支持的界面方向的所有项目。对于所有方向,viewControllers都返回 true (在info-plist中设置),并且不遵守上述代码。即使没有上述代码,IT也能正常工作。反正是否限制特定类的某些支持的接口方向?我按照使其适用于iOS6之前的版本。

Prior, I checked all the items for Supported interface orientations in the info-plist. Both the viewControllers returned true(as set in the info-plist) for all the orientations and didn't obey the above code. IT worked even in the absence of the above code. Is there anyway to restrict certain Supported interface orientations for particular classes? I made it working for the pre - iOS6 versions by following this link.

推荐答案

我能够通过将支持的定向逻辑放在自定义UINavigationController中来实现这一目标。然后我转到相关的视图控制器。

I was able to accomplish this by placing my supported orientation logic in a custom UINavigationController. I then segue to the relevant view controller.

@implementation PortraitNavigationController

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

...

这篇关于为不同的UIViewControllers设置不同的supportedInterfaceOrientations的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 19:47