gpt4 book ai didi

ios - 通用应用程序以纵向模式启动,即使它仅限于横向

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

无论何时在 iPad 上运行模拟,即使在常规设置和代码中它被限制为横向模式,它也会以纵向启动然后切换到横向。问题是当它启动时,所有游戏对象在方向改变之前都被绘制到屏幕上,导致对象被绘制到查看区域下方。用 iPad 横屏模式模拟启动时,一切正常。我怎样才能防止这种情况发生?

我在 GameViewController.swift 中的代码:

override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientationMask.Landscape.rawValue)
}

最佳答案

对于swift3.0

要限制不同 View 的不同方向,您需要执行以下操作:

在应用委托(delegate)文件中:

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

if self.window?.rootViewController?.presentedViewController is OtherViewController {

return UIInterfaceOrientationMask.All;

} else {
return UIInterfaceOrientationMask.Portrait;
}

}

关于ios - 通用应用程序以纵向模式启动,即使它仅限于横向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29727387/

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