2

Possible Duplicate:
Autorotate in iOS 6 has strange behaviour

I have issue with IOS 6, the display show up as portrait and not as landscape. I am using both real and simulator device, if I build the game on 5.1 simulator the view is properly presented if I am using simulator version 6 or the real device with version 6 the view is get portrait view. Here is my code.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
       interfaceOrientation == UIInterfaceOrientationLandscapeRight )
        return YES;

Any idea how to solve such issue?

Thanks ER

Community
  • 1
  • 1
  • 1
    Oh come on, this has been covered extensively in Apples documentation and release notes and there are thousands of questions regarding the new autorotation behaviour in iOS 6 on Stack Overflow. – JustSid Nov 04 '12 at 19:47
  • `shouldAutorotateToInterfaceOrientation` is deprecated in iOS 6. Check out UIViewController documentation.. – beryllium Nov 04 '12 at 19:48

3 Answers3

1

ShouldAutoRotation does not work anymore for iOS 6. Use supportedInterfaceOrientations instead.

You can get more information here: http://dhilipsiva.blogspot.com/2012/07/ios-6-ui-interface-orientation.html

Hope this helps.

FD_
  • 12,947
  • 4
  • 35
  • 62
1

The method shouldAutorotateToInterfaceOrientation has been deprecated for iOS 6. It has been replaced with the following:

- (BOOL)shouldAutoRotate {

    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskLandscape;
}

Also, there's a VERY important detail to make this work. In your AppDelegate, make sure you change the following:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [self.window setRootViewController:<your main view controller here>];
}

If you're using [self.window addSubview:self.mainViewController.view], it won't work.

Simon Germain
  • 6,834
  • 1
  • 27
  • 42
  • Still have the same issue, I applied the following: –  Nov 04 '12 at 20:01
  • - (BOOL)shouldAutorotate { return YES; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationLandscapeLeft; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeLeft; } –  Nov 04 '12 at 20:02
  • Hold on, I know I ran into this problem before. Let me look up what I did. – Simon Germain Nov 04 '12 at 20:04
0

If you want to support iOS 5 as well as iOS 6, leave shouldAutorotateToInterfaceOrientation in your code; just know that it won't be called on iOS6 devices.

The example @Simon gave should be able to coexist peacefully with your original code, with either operating system calling its applicable method. I was able to implement something similar in my app, but I used the project settings to set up autorotation for iOS 6 and just left my shouldAutorotateToInterfaceOrientation alone to make the app compatible with iOS 5 too.

Jeanne
  • 87
  • 1
  • 8
  • Thanks the example Simon give me does not really work I still have issues the view still in portrait view and not in landscape you mentioned you used project setting, do you refer to the info.plist setting... it does not work for me either.. –  Nov 04 '12 at 20:18