1

In my application's build settings, i have all supported orientations (besides upside down) checked.

However, when i launch the app, certain views that are not meant to show in Portrait will auto rotate and cutoff half the view. I do not want these views to rotate.

How can i prevent this? ive tried using:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
    return YES;
if(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    return YES;

return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

But the device still wants to turn portrait when it can. Any help would be great.

nworksdev
  • 235
  • 3
  • 11

3 Answers3

0

This method is deprecated and will not be called in iOS 6. See Apple's documentation or one of the thousand questions on SO about the new methods for more information.

borrrden
  • 33,256
  • 8
  • 74
  • 109
0

Is the view you don't want to rotate embedded in a navigation or tab Bar? I faced this same exact problem if so. You need to assign a class to the tab Bar/ nav bar and override the new method for ios 6 as:

-(BOOL)shouldAutoRotate
{
return NO;
}

Let me know if this is your type of problem. I also had to implement orientation changes using the NSNotificationCenter in order to allow rotation on one of my subviews. I'll post up how if this is what your looking for.

Let me know!

Tommy Devoy
  • 13,441
  • 3
  • 48
  • 75
0

shouldAutorotateToInterfaceOrientation is deprecated. The new replacement is shouldAutoRotate. In order to descern between interface orientations before returning a value for shouldAutoRotate, use the interfaceOrientation property of UIViewControllers. For example, you could have something like this:

-(BOOL)shouldAutoRotate{
    if (self.interfaceOrientation == UIInterfaceOrientationPortrait){
        return YES;
    }
    else {
        return NO;
    }
}
WolfLink
  • 3,308
  • 2
  • 26
  • 44