Search code examples
ipadlandscaperetina-display

iPad orientation issues


I developed an iPhone-only application and now I am making it universal. On iPhone it will run in portrait orientation, while on iPad I want to force it to run in landscape orientation.

I am facing a strange issue, since all the controllers I create for the iPad version seem to have a portrait orientation. I have a main controller, then I usually create more controllers and add their view to the main controller's view. This latter views are created with a frame that fits the portrait orientation and not the landscape one. All these controllers implement the -shouldAutorotateToInterfaceOrientation: and -preferredInterfaceOrientationForPresentation methods to force the landscape mode. Probably this is not sufficient.

Moreover, my biggest issue is with my latest attempt to create a flip-view animation:

[UIView transitionFromView:self.view
                    toView:about.view
                  duration:1
                   options:UIViewAnimationOptionTransitionFlipFromBottom
                completion:^(BOOL finished){
                }];

When I call this method, the new view will appear onscreen but, obviously, it's rotated. Visualization issue

The orange bar should appear on the top of the view, and should occupy all the visible space. Seems like it's in landscape mode but added to the main view with the wrong rotation.

Could you give me hints to solve this?


Solution

  • Apparently to make things work correctly on an iPad you have to use a UINavigationController as the root view controller for the main window. Otherwise you will come to face problems such this one. In fact, setting a navigation controller as the root controller has completely fixed all my problems while handling rotations.