gpt4 book ai didi

objective-c - 顶栏无法在带有 Storyboard的横向 View 中旋转

转载 作者:行者123 更新时间:2023-11-29 04:46:45 25 4
gpt4 key购买 nike

我刚刚从 .nib 文件转换为 Storyboard,但突然 View 不会在横向 View 中旋转顶栏。在我看来,所有设置都是“推断的”,并且自转换以来我没有真正进行任何更改。

这是升级时的常见问题吗?我没有找到任何具体信息。

此外,我不会在代码中强制进行任何 View 旋转。

如果需要更多信息,我可以提供任何信息!

提前致谢。

View Controller :

- (void) viewDidLoad {
[super viewDidLoad];
self.view.autoresizingMask = UIViewAutoresizingNone;
self.view.autoresizesSubviews = UIViewAutoresizingNone;
}

最佳答案

我查看了您的代码,您似乎缺少一种允许 View Controller 自由旋转的方法。

子类 UIViewController 例如像这样:

// .h file
@interface OrientationAwareViewController : UIViewController
@end

// m.file
@implementation OrientationAwareViewController

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}

@end

然后在 Storyboard中设置OrientationAwareViewController作为主视图 Controller 的类名。也就是说,我不知道在使用 Nib 时这对您有何作用:) Documentation说得很清楚:

By default, this method returns YES for the UIInterfaceOrientationPortrait orientation only. If your view controller supports additional orientations, override this method and return YES for all orientations it supports.

关于objective-c - 顶栏无法在带有 Storyboard的横向 View 中旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9522418/

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