gpt4 book ai didi

ios - 如何禁用 UINavigationController Root View Controller 的自动旋转?

转载 作者:行者123 更新时间:2023-11-28 08:42:39 25 4
gpt4 key购买 nike

我需要在我的应用程序中支持所有界面方向掩码。有些 View Controller 不应该自动旋转(它只支持纵向),但应用程序仍然需要支持所有方向。 Expected result

我尝试设置 shouldAutorotate = true; UINavigationController 中的 supportedInterfaceOrientations = AllshouldAutorotate = false; supportedInterfaceOrientations = Portrait 在 Root View Controller 中。但它不起作用。

最佳答案

您可以在仅支持纵向模式的 viewController 中使用它

override func shouldAutorotate() -> Bool {
if (UIDevice.currentDevice().orientation == UIDeviceOrientation.Portrait ||
UIDevice.currentDevice().orientation == UIDeviceOrientation.PortraitUpsideDown ||
UIDevice.currentDevice().orientation == UIDeviceOrientation.Unknown) {
return true;
} else {
return false;
}
}

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.Portrait
}

关于ios - 如何禁用 UINavigationController Root View Controller 的自动旋转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36082596/

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