iOS + SpriteKit:如何强制纵向模式?

sal*_*inx 4 orientation screen-orientation uiinterfaceorientation ios sprite-kit

我目前正在开发适用于iOS 7+和XCode 6的SpriteKit游戏.游戏应始终以纵向模式呈现.到目前为止,我已在视图控制器中实现了这些方法:

- (BOOL)shouldAutorotate {
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

只要我启动应用程序将我的iPad保持在纵向模式,这样就可以正常工作.在游戏过程中它不会切换方向.

但是,在应用程序启动期间以横向方向按住iPad时,游戏会以横向显示.

即使在启动期间设备以横向模式保持,如何强制应用程序以纵向模式显示?

Har*_*ish 11

解决应用方向问题

Go to your projects plist file (should be "YourApp-Info.plist")
Add a row and enter "Supported interface orientations"
Add the orientations that your app supports 
Run Code Online (Sandbox Code Playgroud)

  • 谢谢.Info.plist文件中有两个条目.一个通用的"支持的界面方向"和一个特定的iPad"支持的界面方向(iPad)",我必须调整,以解决问题. (2认同)