1

I develop a simple game in iPhone. The whole game is in landscape mode, but the scoreboard page only support portrait mode. I have checked the questions here, I only find turn portrait into landscape mode, but I need the opposite answer. Could anyone help me?

Eimantas
  • 48,927
  • 17
  • 132
  • 168
Toygirl
  • 79
  • 7
  • here is same thread http://stackoverflow.com/questions/12577879/shouldautorotatetointerfaceorientation-is-not-working-in-ios-6/12581799#12581799 – Kamar Shad Nov 13 '12 at 07:35

2 Answers2

0

I used these two calls in AppDelegate. Getting game center(score board) in landscape only.

// Supported orientations: Landscape. Customize it for your own needs
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}



#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
    return UIInterfaceOrientationMaskAllButUpsideDown; //Getting error here? then update ur xcode to 4.5+
}
#endif

Xcode settings: Mark landscape. enter image description here

Guru
  • 21,652
  • 10
  • 63
  • 102
  • shouldAutorotateToInterfaceOrientation is deprecated as of iOS 6. – WolfLink Nov 13 '12 at 07:34
  • @WolfLink, yes, supportedInterfaceOrientationsForWindow is used for ios6 in my code..its working great:) anyway thanks – Guru Nov 13 '12 at 07:41
0

It's very simple. First, make sure both portrait and landscape orientations are supported in the target summary. Then:

In the landscape ViewControllers, add this:

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

And in the portrait ViewController, add this:

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}
WolfLink
  • 3,308
  • 2
  • 26
  • 44