1
votes

just updated to IOS SDK 6 and now I'm confused. Tried to find a solution but I failed.

  1. Created a new "Single View iPad APP" (I have an iPad 3) in xcode
  2. Disabled Portrait & Upside-Down interface orientations in TARGETS->Summary
  3. Set simulated metrics "orientation" to "Landscape"
  4. Added following lines of code into the view controller file:

    - (BOOL)shouldAutorotate {
         return YES;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
        return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
    }
    
    - (NSUInteger)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskLandscape;
    }
    
    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
        NSLog(@"%@", NSStringFromCGRect(self.view.frame));
    }
    
  5. Run APP

My output is: 2012-10-09 18:18:40.149 TestApp[6165:907] {{20, 0}, {748, 1024}} Does anybody know why the frame is not ... {{0, 20}, {1024, 748}} as I would expect? Maybe I missed something!

Thank you!

1

1 Answers

0
votes

I don't think you missed anything, but if you wrap your view controller with a UINavigationController, the frame will be set as expected.

NB: With the iOS 6 SDK, you can no longer combine any of the UIInterfaceOrientation constants as a mask. So you need:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft;
}

That doesn't explain the issue, though, since preferredInterfaceOrientationForPresentation is not called when a view controller is the root controller of a UIWindow.