大家 . 我正在使用Xcode 9制作应用程序,使用SpriteKit制作swift 4,我希望游戏处于横向模式 .
我已尝试在项目设置中设置仅允许横向并已在app委托文件中添加此代码 .
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
//make device portrait unless it is the game view controller
if self.window?.rootViewController?.presentedViewController is GameViewController {
return UIInterfaceOrientationMask.landscape;
} else {
return UIInterfaceOrientationMask.portrait;
}
}
但是这些工作都没有,SpriteKit场景仍然是纵向加载的 . 如何在场景中加载场景 .
1 回答
转到项目中的info.plist,底部应该是两个元素,“支持的界面方向”和“支持的界面方向(iPad)” . 单击下拉列表并从两个元素中删除纵向模式方向 .