0

On iPhone - my first ViewController supports all interface orientations. Initial behavior though, is when I launch the app the main ViewController should always be in portrait.

In order to overcome situations where the phone was in landscape while the app was launched, I created a dummy ViewController which only supported portrait orientation, launched the app from it and immediately pushed the main ViewController. Indeed the main ViewController was in portrait orientation, but when performing:

self.interfaceOrientation

The result was landscape orientation (like the phone's orientation).
I would expect it to return portrait, and this is causing problems.
How can I get the true orientation of the ViewController and not the device in this case?

Soumya Ranjan
  • 4,817
  • 2
  • 26
  • 51
Avba
  • 14,822
  • 20
  • 92
  • 192

2 Answers2

0

You need to override your UINavController to set the orientation in portrait when you want. It's that Vihba means.

The problem is that navController keeps orientation of last view...

Plokstorm
  • 27
  • 1
-1

**Use this code *****

Also you can refer following link: How to force a UIViewController to Portrait orientation in iOS 6

@implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate

{

return [[self.viewControllers lastObject] shouldAutorotate];

}

-(NSUInteger)supportedInterfaceOrientations

{

return [[self.viewControllers lastObject] supportedInterfaceOrientations];

}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{

    return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];

}
Community
  • 1
  • 1
Vibha Singh
  • 623
  • 4
  • 9