ios 6中的UITabBarController轮换问题 [英] UITabBarController Rotation Issues in ios 6

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

问题描述

的Ack!我最终在iOS 5中解决了我的tabbar旋转问题,但是iOS 6和xcode似乎已经破坏了......这就是我所拥有的:

Ack! I had my tabbar rotation issues resolved finally in iOS 5, but iOS 6 and xcode seem to have broken things... here is what I have:

目标应用程序摘要包括:支持的界面方向 - Portraint,横向左侧,横向右侧

Target App Summary includes: Supported Interface Orientations - Portraint, Landscape Left, Landscape Right

应用程序中的每个单一视图都有以下方法:

Every Single View in the App has the following methods:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    return ((interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown) &&
            (interfaceOrientation != UIInterfaceOrientationLandscapeLeft) &&
            (interfaceOrientation != UIInterfaceOrientationLandscapeRight));
} else {
    return YES;
}
}

- (BOOL)shouldAutorotate
{
NSLog(@"am I called1?");
return NO;
}

-(NSUInteger)supportedInterfaceOrientations{
   NSLog(@"am I called?");
   return UIInterfaceOrientationMaskPortrait;
}

在不属于标签栏的视图中,旋转被阻止。在Tabbar的所有视图中(有5个),应用程序从不调用ShouldAutorotate,因此旋转。它确实看起来supportInterfaceOrientations在视图加载时被调用一次,但是当我在视图之间切换时它不会被调用,因为我得到了NSLog,但似乎忽略了MaskPortrait设置。

In the views that are not part of the tab bar, rotation is blocked. In ALL the views of the tabbar (there are 5) the app never calls ShouldAutorotate and so rotates. It does seem supportedInterfaceOrientations gets called once when a view loads, but not when it appears if I switch between views, because I get the NSLog, but it seems to ignore the MaskPortrait setting.

我必须在目标中启用横向,因为我有一个需要旋转的视频播放器视图(并且这样做,很好)

I have to leave the landscape enabled in the target because I have a single video player view that needs to rotate (and it does so, fine)

这是iOS 6中的tabbar错误?我是否需要以不同方式禁用视图的旋转? shouldautorotatetointerfaceorientation在ios 5中运作良好

Is this a tabbar bug in iOS 6? Do I need to disable the rotation of the views differently? The shouldautorotatetointerfaceorientation worked great in ios 5

我已经有一段时间了

谢谢,
Zack

Thanks, Zack

推荐答案

Zack,我遇到了同样的问题。这是因为你将viewController嵌入到TabBar控制器或UINavigationController中,并且这些方法的调用发生在那些方法中,而不是普通的View(在iOS6中更改)。

Zack, I ran into this same issue. It's because you have your viewController embedded inside of a TabBar Controller or UINavigationController and the calls to these methods are happening inside those instead of your normal View (Changed in iOS6).

我遇到了这个问题,因为我在我的所有模态视图中呈现了嵌入在UINavigationController中的viewController,这些视图具有导航到不同视图(注册过程,登录等)。

I ran into this issue because I was presenting a viewController embedded inside a UINavigationController on all my modal views that had Navigation to different views (Signup Process, Login, etc).

我的简单修复是为UINavigationController创建一个包含这两种方法的CATEGORY。我无论如何都应该返回NO,因为我不希望我的模态视图旋转。你的修复可能很简单,试一试。希望它有所帮助。

My simple fix was to create a CATEGORY for UINavigationController that includes these two methods. I have shouldAutorotate returning NO anyway because I don't want my modal views rotating. Your fix may be this simple, give it a try. Hope it helps.

我创建了一个类别并将其命名为autoRotate并选择了UINavigationController选项。 M + H文件在下面。

I created a category and named it autoRotate and selected theUINavigationController option. The M+H file are below.

#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

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

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