gpt4 book ai didi

ios - 我无法在单个屏幕上旋转我的肖像应用程序

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

enter image description here

这是我 Storyboard的一部分,我尝试过,但无法处理。

我在 navigationController 中尝试过,但没有成功。你有什么建议吗?

override var shouldAutorotate : Bool {
if self.topViewController != nil{
return self.topViewController!.shouldAutorotate
}else{
return super.shouldAutorotate
}
}

override var supportedInterfaceOrientations : UIInterfaceOrientationMask {
if self.topViewController != nil{
return self.topViewController!.supportedInterfaceOrientations
}else{
return super.supportedInterfaceOrientations
}
}

override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation{
if self.topViewController != nil{
return self.topViewController!.preferredInterfaceOrientationForPresentation
}else{
return super.preferredInterfaceOrientationForPresentation
}
}

override var preferredStatusBarStyle : UIStatusBarStyle {
return self.topViewController!.preferredStatusBarStyle
}

最佳答案

您可以将此应用程序生命周期方法 supportedInterfaceOrientationsFor 添加到您的应用程序委托(delegate)类中,以根据您的要求支持各种方向。

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {

if self.window?.rootViewController != nil {

if self.window!.rootViewController! is UITabBarController {

if self.window?.rootViewController?.childViewControllers.last is UINavigationController {

if self.window?.rootViewController?.childViewControllers.last?.childViewControllers.last is YourViewController {
return UIInterfaceOrientationMask.all;
} else {
return UIInterfaceOrientationMask.portrait;
}

} else {
if self.window!.rootViewController?.childViewControllers.last is YourViewController {
return UIInterfaceOrientationMask.all;
} else {
return UIInterfaceOrientationMask.portrait;
}
}
}
}
}

关于ios - 我无法在单个屏幕上旋转我的肖像应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48801788/

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