2
votes

I am upgrading a legacy app to iOS 6, which only supports landscape orientation. When I run the app in the iPhone simulator or on my iPhone 4, the orientation of the root view controller is in portrait mode when it is supposed to be in landscape right. The keyboard is in the correct position initially, however. In addition, when I rotate the device, the keyboard sticks to its initial orientation, and the root view never changes orientation.

In the Supported Interface Orientations section of the project settings, the Landscape Left and Landscape Right buttons are selected. In the pList file, Landscape (right home button) is set for Initial Interface Orientation, and Landscape (right home button) and Landscape (left home button) are set for Supported interface orientations.

Also, in the root view controller, I have replaced this code:

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
BOOL rotate = NO;

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

return rotate;
 }

With this code:

 - (NSUInteger)supportedInterfaceOrientations {

return UIInterfaceOrientationMaskLandscape;

 }

 - (BOOL)shouldAutorotate {

return YES;

 }

Any ideas?

1
FYI: If you are only deploying on iOS 6+, then you can replace the code (as you have done) but if you also need to deploy on iOS 5 then you must keep both sections of code. - Robotic Cat

1 Answers

1
votes

I had the same situation updating my legacy app to iOS 6. You can check that post for my solution:

Rotation behaving differently on iOS6

To summarize, you need to set the main window rootViewController property to a custom navigation controller implementing shouldAutorotate and supportedInterfaceOrientation then voilĂ , it should work properly!