2

My iPad app contains a single view somewhere in the app that supports landscape mode.

For the shouldAutorotateToInterfaceOrientation in that view to be called I had to declare in the info.plist that landscape is supported.

Problem:

The UITabController which is shown when the app is launched doesn't support landscape mode and I made sure to specify it in all the tabbar's view controller. Yet, when the app is launched while the device is in landscape mode, the tabcontroller is shown in landscape and all the tabs looks distorted.

Setting the info.plist to support only portrait mode forces the app to launch correctly, but then the shouldAutorotateToInterfaceOrientation is ignored on the rotatable viewcontroller.

Another option I tried upon launch is:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

That actually forced the app to show in portrait, but also made the app ignore further device rotation on the rotatable viewcontroller.

Update: This is iOS6 issue only and cannot be spotted on the simulator

Aviel
  • 307
  • 3
  • 11

1 Answers1

2

Check this iOS 6 rotations: supportedInterfaceOrientations doesn´t work?

You need to subclass your TabBarController and override its shouldAutoRotateToInterfaceOrientation to control how this ViewController orients itself.

Community
  • 1
  • 1
CSmith
  • 13,318
  • 3
  • 39
  • 42
  • 3
    On the spot! it's an iOS6 issue only (DOH).I already subclassed my tab but _shouldAutoRotateToInterfaceOrientation_ didn't affect.In iOS6 _shouldAutorotate_ should return YES and _supportedInterfaceOrientations_ should return portrait. Besides, that 70% of the story, for the status bar to align with the supported orientation makes sure you use `[window setRootViewController:tabBarController]` is used if you are handling some legacy code, like [suggested here](http://stackoverflow.com/a/12507408/319885). – Aviel Oct 06 '12 at 09:23
  • @CSmith, bro could you please take a look at my problem https://stackoverflow.com/questions/46127376/rotating-only-affect-one-time-in-ipad-in-swift-3 ? – May Phyu Sep 09 '17 at 08:25