所有人。我正在用Xcode9和swift 4和SpriteKit做一个应用程序,我想让游戏处于横向模式。
我已经尝试在项目设置中设置为只允许横向,并在应用程序委托文件中添加了此代码。
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场景仍然加载在肖像中。如何将场景加载到景观中。
发布于 2017-12-20 11:17:58
转到项目中的info.plist,底部应该有两个元素,“支持的接口方向”和“支持的接口方向(IPad)”。单击下拉菜单并从两个元素中删除纵向模式方向。
https://stackoverflow.com/questions/47895138
复制相似问题