问题描述
确认!我终于在 iOS 5 中解决了我的标签栏旋转问题,但 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:
目标应用摘要包括:支持的界面方向 - 纵向、左侧横向、右侧横向
Target App Summary includes: Supported Interface Orientations - Portraint, Landscape Left, Landscape Right
App 中的每个 Single View 都有以下方法:
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;
}
在不属于标签栏的视图中,旋转被阻止.在标签栏的所有视图(有 5 个)中,应用程序从不调用 ShouldAutorotate 并因此旋转.似乎supportedInterfaceOrientations在视图加载时被调用一次,但在我在视图之间切换时不会出现,因为我得到了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 中的标签栏错误吗?我是否需要以不同的方式禁用视图的旋转?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,我也遇到了同样的问题.这是因为您将 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.我有 shouldAutorotate 无论如何都返回 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 旋转问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!