UITabBarController/UINavigationController旋转问题 [英] UITabBarController/UINavigationController rotation issues

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

问题描述

我的问题如下:我只希望在我所有的ViewController上允许纵向取向,但1个ViewController应该允许纵向和landscapeLeft/Right除外.现在,我已经花了将近2天的时间来研究如何在IOS中为不同的幻灯片/ViewController设置方向.经过一番搜索后,我在堆栈中找到了该线程: ios中的UITabBarController旋转问题6

My problem is the following: I want to only allow Portrait orientation on all my ViewControllers except 1 ViewController which is supposed to allow both Portrait and landscapeLeft/Right. I have now spent almost 2 days into how to set orientation in IOS for different slides/ViewControllers. After some searching I found this thread here at stack: UITabBarController Rotation Issues in ios 6

我在该线程中遵循了Kunani的示例,我将在此处发布此示例,以节省所有读者一些时间:

Zack,我遇到了同样的问题.这是因为您将viewController嵌入在TabBar Controller或UINavigationController内,并且对这些方法的调用发生在这些方法而不是常规View内(在iOS6中已更改).我遇到了这个问题,因为我在所有导航到不同视图(注册过程,登录等)的模态视图上都呈现了一个嵌入在UINavigationController中的viewController.我的简单修补是为UINavigationController创建一个包含这两个方法的CATEGORY.无论如何,我应该应该自动返回NO,因为我不希望旋转模态视图.您的修复可能很简单,请尝试一下.希望能帮助到你.我创建了一个类别并将其命名为autoRotate,并选择了UINavigationController选项. M + H文件在下面.

#import "UINavigationController+autoRotate.h"

@implementation UINavigationController (autoRotate)

-(BOOL)shouldAutorotate {
return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

@end

...和类别.h:

 #import <UIKit/UIKit.h>

 @interface UINavigationController (autoRotate)

-(BOOL)shouldAutorotate;
- (NSUInteger)supportedInterfaceOrientations;

@end

我按照他说的做了,并尝试为我的UITabBarController设置类别,该类别可以正常工作,所有连接到tabBar的类现在都只允许orientationPortrait.但是,如果您看下面的图片

I did what he said and tried to set category for my UITabBarController which worked, all classes connected to the tabBar now only allows orientationPortrait. But if you look at the following Picture

(我的项目的屏幕截图)在StoryBoard的中间有一个名为ShowTaskView的类.此类通过UINavigationController连接到大多数类(直接连接到UITabBarController).即使我将UITabBarController设置为仅允许Portrait,ShowTaskView似乎也受到该规则的影响,并且我无法使其旋转.我项目中的方案也可以这样描述:

(screenshot from my project) there is a class in the middle of the StoryBoard called ShowTaskView. This class is connected to most classes (which are directly connected to the UITabBarController) via a UINavigationController. Even if I set UITabBarController to only allow Portrait also ShowTaskView seems to get affected by that rule and I can not make it to rotate. The scheme in my project can also be described as this:

TabBarController ----> UINavigationController -------> class X ----------> class ShowTaskView

如果我希望将连接到tabBarController的类仅允许DirectionalPortrait,而其余类根据我的项目的构建方式同时允许纵向和横向,该怎么办呢?我对这个问题感到非常沮丧,因为它真是难以解决:/

What can I do from here if I want my classes connected to tabBarController only to allow orientationPortrait and the rest of the classes allow both portrait and landscape based on how my project is built? I am very frustrated at this issue since it is so damn hard to solve :/

致谢

推荐答案

请在相似的线程中引用我的答案:

please refer to my answer in similar thread: Navigation controller stack in landscape mode, but modally presented view controller view always in portrait frame size

iOS6通过导航堆栈控制旋转,因此将可旋转视图包装到单独的导航控制器中,以便在那里进行控制.

iOS6 controls rotation by the navigation stacks, so wrap your rotatable view into separate navigation controller to be able to control it there.

这篇关于UITabBarController/UINavigationController旋转问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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