gpt4 book ai didi

ios - 应用程序启动后 iPad 应用程序界面方向发生变化

转载 作者:行者123 更新时间:2023-11-28 22:22:49 24 4
gpt4 key购买 nike

我正在开发应用程序。应用程序的方向是横向的,但在应用程序运行后,应用程序的界面方向会改变界面并旋转。启动画面以正确的方式显示(横向)。我正在使用 ios7,该应用程序是 ios5 的代码,我认为存在一些已弃用的 api 问题,例如调用 shouldAutorotateToInterfaceOrientation 机器人,因为这在最新的 ios 中不再可用

enter image description here

最佳答案

如果您希望我们所有的导航 Controller 都尊重顶 View Controller ,您可以使用一个类别,这样您就不必遍历并更改一堆类名。

 @implementation UINavigationController (Rotation_IOS6)

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

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

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

@end

正如一些评论指出的那样,这是对问题的快速修复。更好的解决方案是子类化 UINavigationController 并将这些方法放在那里。子类也有助于支持 6 和 7。

关于ios - 应用程序启动后 iPad 应用程序界面方向发生变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19852408/

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