0

I'm trying to work with the iOS6 Auto-rotation mess.

I've looked at almost every single SO question relating to it, and no matter what I try, I can't get rotation working how I need it.

The app is using storyboards, and the layout is as follows:

Navigation controller ---> Root view controller ---> Tab view controller ---> View controller ---> Landscape view controller.

The view controller auto-rotates when I rotate the simulator, but when segueing back to the previous view (that is set to portrait), the view becomes landscape, when it should be portrait. If I rotate the simulator back, the view auto-rotates to portrait again, but this should've been done automatically!

I've implemented (UIInterfaceOrientation)preferredInterfaceOrientationForPresentationand it doesn't get called in any view controller I put it in.

I've subclassed the NavigationController to return the topViewController's shouldAutoRotate, supportedInterfaceOrientations and preferredInterfaceOrientationForPresentation and auto-rotation when rotating the simulator seems to work, but preferredInterfaceOrientationForPresentation never does its job.

Does anyone have a solution to this?

ThisDarkTao
  • 1,062
  • 10
  • 27
  • in interface builder, for each view, there is a section where you can set what it looks like in a given orientation. Have you played with that already? – Pinwheeler May 27 '13 at 21:15
  • Yeah, the orientations in `Simulated Metrics` are set to Portrait and Landscape as appropriate for each view. – ThisDarkTao May 27 '13 at 21:43
  • 1
    preferredInterfaceOrientationForPresentation is only called for modal view controllers. – user1459524 May 27 '13 at 23:27
  • Implement the - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation for each of the view controllers. – Pochi May 28 '13 at 00:35
  • have you set orientations in info.plist file?? – NiravPatel May 28 '13 at 04:39
  • shouldAutorotateToInterfaceOrientation doesn't get called, and I have the orientations set in the Info.plist. – ThisDarkTao May 28 '13 at 08:02

1 Answers1

0

It would appear Apple have removed the ability to push a view in a specific orientation. preferredInterfaceOrientationForPresentation does get called, but only when popping back or presenting a view controller. I had to present my landscape view rather than push it, and set shouldAutoRotate = NO.

Refer to: In iOS6, trouble forcing ViewController to certain interfaceOrientation when pushed on stack for more details.

Community
  • 1
  • 1
ThisDarkTao
  • 1,062
  • 10
  • 27