0

In my application i got 2 UIViewControllers, first is root controller in UINavigationController and second is called by first one by pushing to UINavigationController's stack.

So first view should be only in portrait orientation, when second should support all orientations.

I wrote in first this code:

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

But it still rotating to all orientations. Why?

Eugene Trapeznikov
  • 3,220
  • 6
  • 47
  • 74

4 Answers4

0

May i know what IOS version you are using? This method is deprecated for IOS 6

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

Please check following URL the voted answer is some what you might be looking for

UITabBarController Rotation Issues in ios 6

Community
  • 1
  • 1
Deepesh Gairola
  • 1,252
  • 12
  • 18
0

I create category for UINavigationController. it described here

How to force a UIViewController to Portrait orientation in iOS 6

Community
  • 1
  • 1
Eugene Trapeznikov
  • 3,220
  • 6
  • 47
  • 74
0

Best way for you to do this is change the Supported orientations in the APP summary to the ones you like (Portrait orientation) only.

enter image description here

Then you can handle the other pages orientation delegate methods.

-(BOOL)shouldAutorotate{
return YES;

}

-(NSInteger)supportedInterfaceOrientations{ NSInteger mask = 0; if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeRight]) mask |= UIInterfaceOrientationMaskLandscapeRight; if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeLeft]) mask |= UIInterfaceOrientationMaskLandscapeLeft; if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationPortrait]) mask |= UIInterfaceOrientationMaskPortrait; if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationPortraitUpsideDown]) mask |= UIInterfaceOrientationMaskPortraitUpsideDown; return mask; }

Praveen Kumar
  • 1,338
  • 3
  • 20
  • 31
  • if i choose only portrait orientation in Summary, nothing rotate (( – Eugene Trapeznikov Apr 23 '13 at 11:19
  • Here is the trick. If you set the Portrait mode only in App summary, App will launch in the portrait mode and then you can handle the orientation changes in any of the view controllers and it will work accordingly. If you are trying it in device, please make sure, your orientation lock is switched off. – Praveen Kumar Apr 23 '13 at 11:29
  • Can you also please check if you are making any changes to the status bar orientation? – Praveen Kumar Apr 24 '13 at 09:24
0

I didn't use uinavigationcontroller, but instead used presentmodalviewcontroller. This allowed me to use different orientation management.

George Duckett
  • 31,770
  • 9
  • 95
  • 162
Eugene Trapeznikov
  • 3,220
  • 6
  • 47
  • 74