0

I'm using the Master-detail template in xcode4.5.1 to create an universal app. To keep landscape in iPad, I have following settings. It works in iOS6, but always keep portrait in iOS5. How can I solve the issue? ( project linkage: https://www.dropbox.com/s/7wm9l8kxhan6kp1/itstest.zip

  1. plist

    <key>UISupportedInterfaceOrientations~ipad</key>
    
    <array>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
    
    </array>
    
    <key>UISupportedInterfaceOrientations~iphone</key>
    
    <array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationPortraitUpsideDown</string>
    
    </array>
    
  2. even add following in Appdelegate.m

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    }
    

Thanks!

sooper
  • 5,991
  • 6
  • 40
  • 65
LiangWang
  • 8,038
  • 8
  • 41
  • 54

1 Answers1

1

The method shouldAutorotateToInterfaceOrientation does not get called in your AppDelegate, only in your View Controllers (docs). Place the following code inside your view controllers (Although for your particular project I think it would be enough to place it only inside your MasterViewController):

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        return UIInterfaceOrientationIsPortrait(interfaceOrientation);
    else
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
sooper
  • 5,991
  • 6
  • 40
  • 65