gpt4 book ai didi

ios - UITabBarController 内的 UINavigationController 不会在 iOS 6 中旋转

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:47:04 28 4
gpt4 key购买 nike

我在 UITabBarController 中有一个 UINavigationController。我尝试了社区建议的所有关于 iOS 6 中自动旋转的建议,但都没有成功,最后我决定为 UINavigationController 创建一个类别,它没有对 oriantaion 进行任何更改(尽管函数确实被调用)

enter image description here

然后我像这样为 UITabBarController 创建了一个类别:

#import "UITabBarController+ios6Rotate.h"

@implementation UITabBarController (ios6Rotate)

-(BOOL)shouldAutorotate
{
return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortraitUpsideDown;;
}

@end

得到这个:

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!

但是我所有的方向都支持?!嗯

然后我把代码改成这样:

-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortraitUpsideDown;
}

这让我的应用开始颠倒,但仍然无法旋转。我不明白这是怎么回事。在这一点上,我希望在 ios6 中看到任何类型的旋转,我不在乎向哪一边但似乎没有任何效果。

最佳答案

您应该确保添加正确的 supportedInterfaceOrientations。您可以尝试在您的类别中调用相应的 viewController 的方向方法。

例如在 UINavigationController 类别中它会是这样的

-(BOOL)shouldAutorotate
{
return [self.topViewController shouldAutorotate];
}

-(NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.topViewController preferredInterfaceOrientationForPresentation];
}

关于ios - UITabBarController 内的 UINavigationController 不会在 iOS 6 中旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15876005/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com