gpt4 book ai didi

iphone - 原力风景 iOS 6

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

我希望我的应用程序中的一个 View 具有横向方向。我设法让 View 在手动旋转时保持横向,但如果设备已经是纵向的,它会保持纵向,无论其支持的方向如何(使用 supportedInterfaceOrientations 方法设置)。有没有办法让 View 自动旋转?我试过:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];

但这行不通。

如有任何建议,我们将不胜感激!

最佳答案

实现此目的的一种方法是覆盖 preferredInterfaceOrientationForPresentation 但为了调用它,viewController 必须被presented(如在模态中)而不是像提到的那样被推送here :

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
NSLog(@" preferred called");
return UIInterfaceOrientationPortrait;
}

为了在 UINavigationController 中显示您的 viewController,请使用:

UINavigationController *presentedNavController = [[UINavigationController alloc] initWithRootViewController:protraitViewController];

[self presentViewController:presentedNavController animated:YES completion:nil];

要使 UINavigationController 尊重您当前 viewController 的方向首选项,请使用这个简单的 category而不是子类化。

此外,这 part阅读 Apple 文档有助于更好地理解 iOS 方向处理。

关于iphone - 原力风景 iOS 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16132965/

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