iosxcodeuiinterfaceorientationautorotateinterface-orientation

Allow portrait Only - Works in iOS6 but not iOS5


I'm building a project with a Base SDK of iOS 6.0.

In Targets > Summary I've set the Supported Device orientations' to portrait only (the other orientations are unselected).

This works great when I run the app in the 6.0 simulator, the app is locked to portrait as intended. However when I run the the 5.1 simulator, it's supporting both landscape orientations (but not upside down)!?

I want to force portrait throughout every view in the entire app (bar one view controller). Currently when testing in iOS 5.1 it allows rotation no matter what I do.

Despite being depreciated in iOS6, I've kept:

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

but that doesn't do anything.

How can I force portrait only in iOS 5.0 also?


Solution

  • shouldAutorotateToInterfaceOrientation should do the trick. Are you sure it is executing? Are you sure it is defined in your main view controller, not somewhere else?