user1752552
user1752552

Reputation: 45

Upgrading to iOS 6 and RootViewController Orientation Incorrect

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?

Upvotes: 2

Views: 2345

Answers (1)

iMathieuB
iMathieuB

Reputation: 1168

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!

Upvotes: 1

Related Questions