0

First, I want to say that this question does not solve my problem: Orientation problem when I set a RootViewController

My ipad application only works in landscape mode. When I'm changing the root controller, the new storyboard appears correctly. But, it appears in portrait mode and then rotates to the correct orientation. How can I specify the orientation before changing the root controller or tell the storyboards to display in landscape by default ? It is pretty ugly seing the rotation of the view just after the animation.

Also, the landscape left and right are set in the project property.

Here is the code when I change the root view controller.

UIStoryboard *editorStoryboard = [UIStoryboard storyboardWithName:@"EditorStoryboard" bundle:nil];
UISplitViewController *editorViewController = [editorStoryboard instantiateInitialViewController];

UINavigationController *navigationController = [editorViewController.viewControllers lastObject];
editorViewController.delegate = (id)navigationController.topViewController;


AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

[UIView transitionWithView:appDelegate.window duration:0.5 options: UIViewAnimationOptionTransitionFlipFromLeft animations:^{
    appDelegate.window.rootViewController = editorViewController;
} completion:nil];
Community
  • 1
  • 1
Etienne Noël
  • 5,988
  • 6
  • 48
  • 75
  • Have you checked the `Supported Interface Orientations` are selected only `Landscape Left` or `Landscape Right`(as per your need) in the Application Targets Summary – Sumanth Jan 29 '13 at 13:25
  • Yes, they are checked, forgot to add it – Etienne Noël Jan 29 '13 at 13:28
  • If they are checked the details are saved in Info.plist so application will load with portrait mode initially. So only select Landscape mode – Sumanth Jan 29 '13 at 13:29
  • I meant landscape left and right are checked. – Etienne Noël Jan 29 '13 at 13:47
  • I found answer. This is work fine. [http://stackoverflow.com/questions/8053832/rootviewcontroller-animation-transition-initial-orientation-is-wrong][1] [1]: http://stackoverflow.com/questions/8053832/rootviewcontroller-animation-transition-initial-orientation-is-wrong – ttt Nov 29 '13 at 05:56

1 Answers1

0

Did you try to override the

preferredInterfaceOrientationForPresentation

for the new root viewcontroller? Something like this:

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscape
}

This from the View Controller Programming Guide for iOS

EDIT: ok, what about trying to get rid of the animation?

user1459524
  • 3,613
  • 4
  • 19
  • 28