0

I'm developing an iOS6 App with storyboards and i'm encountering an unexpected beahviour. My app is almost in portrait mode , and i would keep this orientation in all the views except two.For this reason the project supports both landscape and portrait mode, i've subclassed navigation controller with a category (as explained almost everywhere :-)in Appdelegate.m and every view controller implements

- (NSUInteger)supportedInterfaceOrientations{
 return UIInterfaceOrientationMaskPortrait; (landscape where needed)
}

and

-(BOOL)shouldAutorotate{
return YES;
}

Everything seems to work well except the fact that in the transition between a landscape view to a portrait one (not vice versa ?) , all the elements of the ui are displayed in landscape(imagine that you're keeping the phone horizontal), if you turn the phone , the rotation event is fired, the ui turns back in portrait and only now is locked to this orientation.Is there a way to fire the rotation BEFORE the view is presented? Why the shouldAutorotate is not called at the ViewWillAppear stage?

Thank you!

2 Answers2

0

Remove both the above function and try this it should work

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
         Return YES for supported orientations

    }

if still it's not working then try this change the appDelegate

[window addSubview:nav.view];

to this code

 window.rootViewController=nav;
Arun
  • 590
  • 1
  • 9
  • 27
0

I found this online chapter very good for explaining UIViewControllers and rotation.

http://www.apeth.com/iOSBook/ch19.html#Rotation

It s a big page, scroll down to Rotation.

Rob van der Veer
  • 1,148
  • 1
  • 7
  • 20