gpt4 book ai didi

ios - 在 UITabBarController 中强制横向显示特定的 View Controller

转载 作者:行者123 更新时间:2023-11-29 02:21:50 25 4
gpt4 key购买 nike

我在 UITabBarController 中有 5 个导航 Controller 。 UITabBarController 中的 Navigationcontroller 之一有一个Viewcontroller 始终横向显示其他所有纵向..

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

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

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

以上代码我放入NavigationController子类中。

-(BOOL)shouldAutorotate
{
return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}

以上代码是我放入景观 Controller 中的。

我有 Base 作为 UIViewController 子类,我放置了这段代码

-(BOOL)shouldAutorotate
{
return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
if ([self isKindOfClass:[LanscapeViewController class]])
return UIInterfaceOrientationLandscapeLeft;
else
return UIInterfaceOrientationPortrait;
}

如果我展示该 View Controller ,它可以很好地显示该屏幕仅横向。但是,如果我将 ViewController 插入,则仍保持纵向。

最佳答案

您是否在 ViewController 中为纵向模式编写了以下代码。

    -(BOOL)shouldAutorotate
{
return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortraitUpsideDown | UIInterfaceOrientationPortrait;
}

关于ios - 在 UITabBarController 中强制横向显示特定的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28044771/

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