Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS+SpriteKit: How to force portrait mode?

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:

- (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.

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

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

like image 853
salocinx Avatar asked Dec 15 '22 14:12

salocinx


1 Answers

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 
like image 96
Harish Avatar answered Dec 27 '22 11:12

Harish