gpt4 book ai didi

ios - 即使设备在 objective-c 中水平旋转,如何始终以纵向模式加载 UIViewController?

转载 作者:行者123 更新时间:2023-11-29 12:15:05 26 4
gpt4 key购买 nike

我的 UIViewController 处于纵向模式,当我转到另一个 UIViewController 并水平旋转设备然后返回到之前的 UIViewController 时,它的 View 全乱了。我的应用程序支持设备的每个方向,我实现了方法:

- (BOOL)shouldAutorotate {
return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}

但是我无法解决这个问题。如何始终以纵向加载 UIViewContoller,而不管设备方向和先前加载的 UIViewContoller 的方向?感谢您的回答和帮助。

最佳答案

我修好了。 :) 在 vi​​ewDidLoad 中,我放置了这行代码:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

并添加方法:

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotate {
return NO;
}

它工作正常。

关于ios - 即使设备在 objective-c 中水平旋转,如何始终以纵向模式加载 UIViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32220564/

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