gpt4 book ai didi

ios纵向和横向模式

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:36:11 25 4
gpt4 key购买 nike

我有以下场景:

我从 appDelegate 做:

firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController *firstNavController = [[UINavigationController alloc]initWithRootViewController:firstViewController];

firstViewController - 只需要在纵向模式下

为了完成这个我做了:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (BOOL)shouldAutorotate
{
return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}

firstViewController 我正在推送另一个 View Controller ,它需要同时具有纵向和横向功能。

secondViewController 按预期运行 - 在纵向和横向模式下

我在横向模式下显示的 firstViewController 也有问题,尽管我已将其限制为纵向模式。我做错了什么?

最佳答案

在您的项目中使用以下方法添加UINavigationController 类别

#import "UINavigationController+MyNavigation.h"

@implementation UINavigationController (MyNavigation)

-(BOOL)shouldAutorotate
{
return YES;
}

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

这解决了我的问题。

关于ios纵向和横向模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22017786/

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