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

时间:2022-11-15 20:10:07

I'm currently working on a SpriteKit game for iOS 7+ and XCode 6. The game should always be presented in portrait mode. So far I have implemented these methods in my view controller:

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

- (BOOL)shouldAutorotate {
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

This works fine as long as I start the app holding my iPad in portrait mode. It does not switch the orientation during game play.

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

But when holding the iPad in landscape orientation during the app is starting, the game is shown in landscape.

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

How do I force the app to be shown in portrait mode even if the device was held in landscape mode during startup ?

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

1 个解决方案

#1


To solve the app orientation issue

解决应用方向问题

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 

#1


To solve the app orientation issue

解决应用方向问题

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