gpt4 book ai didi

ios - Storyboard忽略 UIInterfaceOrientation 设置

转载 作者:行者123 更新时间:2023-11-29 10:31:01 25 4
gpt4 key购买 nike

UIInterfaceOrientation 有一个奇怪的问题。在我的项目中有许多不同的 View ,其中一些应该以横向模式旋转,而另一些则不应该。问题是所有不是使用 Storyboard 创建的 View ,其中仅启用了 UIInterfaceOrientation 肖像,这工作正常并且 View 不旋转,而是使用 Storyboard 创建的所有 View ,即使UIInterfaceOrientation 横向模式已禁用,它们会一直旋转。在我的 Xcode 项目设置中,这些检查已启用,我无法更改它们:

enter image description here

如何在所有不同的 View 中完全禁用设备旋转? [是否有 Storyboard]。

这是我用来在所有 Storyboard View Controller 中禁用设备方向的代码,但它不起作用:

- (BOOL)shouldAutorotate {
return NO;
}

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

最佳答案

试试这个代码,也许它适合你。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientationMask)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationMaskPortrait);
}

关于ios - Storyboard忽略 UIInterfaceOrientation 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29625862/

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