iPad orientation issues - ipad

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.
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?

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.

Related

Present one view in landscape mode in an otherwise portrait mode app

I have an application (iPhone only) that is portrait-only, but with one exception, a view that must be displayed in landscape mode.
I have implemented the technique described in the accepted answer in How to lock orientation of one view controller to portrait mode only in Swift, albeit in Objective-C.
Since I've overridden the -lockOrientation methods in -viewWillAppear and -viewWillDisappear of the landscape view controller, I don't undertand why I see rotation occur after the view appears; I would have thought that would occur before the view appears.
When my presented landscape view is overlaid by a presented portrait view, the portrait view starts out as landscape (because it's presented over a landscape view before rotation), but the rotated view has only the height it had in landscape mode.
When the portrait view is dismissed, the first, landscape view has now rotated to portrait mode, even though I've also implemented -supportedInterfaceOrientations and -preferredInterfaceOrientationForPresentation for landscape mode. This has been noted in UIViewController orientations, but there didn't appear to be any working solutions posted there.
Both view controllers, the landscape and the portrait that overlays it, are presented rather than pushed.
Also, the only flag set in the project's Info.plist is Portrait. The full-screen flag is not set.
In short, it's a hot mess just trying to make one exception to view orientation in my app.
Any clues to solving the behavior I've described would be greatly appreciated.

Presenting transparent modal UIViewController on iPad iOS 7

I have an iPad app which supports all orientations and has a UITabBarController managing a set of view controllers. Rotation works as expected everywhere. Keep in mind my UITabBarController is the .rootViewController of my app's UIWindow.
I now go to present a UIViewController modally from my UITabBarController. It presents well, and the status bar moves in accordance with the device's orientation. However, my UIViewController's view frame never changes (it is always in portrait dimensions, regardless of how it was presented).
This isn't an issue on iOS 8, and I thought UITabBarController would handle a modal controller on its own. Is there something I'm missing?
Bonus: ultimately this UIViewController will be transparent and reveal the app beneath it. When I try this and rotate my device, none of the regular view controllers rotate.
However, my UIViewController's view frame never changes (it is always in portrait dimensions, regardless of how it was presented).
This is expected. In iOS 7, rotation was implemented by applying a transform to the top-level view controller's view. The application of this transform does not alter the frame, which remains in portrait dimensions. In iOS 8, rotation is implemented at the window level.
Bonus: ultimately this UIViewController will be transparent and reveal the app beneath it. When I try this and rotate my device, none of the regular view controllers rotate.
The UIModalPresentationStyleFullscreen presentation style removes the presenter's view from the window while it is covered by the presented view controller. If you modify the alpha of the presented view controller's view, you'll just see black underneath.
Since UIModalPresentationStyleOverFullscreen did not exist in iOS 7, you would need to use UIModalPresentationStyleCustom with your own transition animator. Unfortunately, custom transitions with view controllers that can rotate is extremely buggy in iOS 7.

iOS7 iPad view is loaded in landscape mode instead of portrait mode

On iOS7, i have a viewController added as a subview to the root view controller like so:
[self.view insertSubview:self.tutorialViewController.view aboveSubview:self.accessoriesView];
What happens is in viewDidLoad and in viewDidAppear, it loads with landscape mode dimensions, instead of portrait.
This also happens on iOS6 and bellow, but somehow it gets resized so this is not an issue. It seems that self.view.frame is not always reliable: http://bynomial.com/blog/?p=85
What could be the cause of this and how can i fix it?

IOS -Loading Nib View with specific orientation

I have a view which is added in the form: [currentView addSubview: viewController.view];
If the view was added like [self presentModalViewController: viewController] then the view is displayed always ok, from landscape and portrait mode.
However, I can't use modal because the view needs to have transparent background and modal converts it to black.
The problem using the first method is that the nib is alway loaded in portrait mode, if the current orientation is portrait everything loads ok, and I can rotate to landscape without problem.
When my device is in landscape mode, the view is loaded as portrait again so it doesn't fit ok in screen.
I tried calling the rotation delegate methods: didRotateWithOrientation, willRotateWithOrientation, willAnimateRotation .. etc., however they don't rotate my view.
Is there any way to load the nib in a specific orientation or to rotate the view before it is added to my other view?
Unfortunately I don't think that this is possible, at least in iOS 4.
Check out this answer:
https://stackoverflow.com/a/4869207/472344
You might better off creating a custom view and adding that instead of a view controller.

iPad Modal View Dismissal Changes Parent View Orientation

I have an iPad Split View Application that brings up a modal view to display certain content. When I bring up the modal (in PageSheet style) and then change from Portrait to Landscape (or vice-versa) and then dismiss the modal the orientation of the detailViewController (the parent of the modal) turns 90 degrees.
So if I am in landscape mode when I close the modal the right pane will turn as if it were in portrait mode but the device is still in Landscape and the rootViewController is still visible. After this happens no rotation will solve the problem until the view is removed.
Any idea what I've screwed up here? I've had a ton of trouble with iPad rotation handling in general but this one is really giving me problems.
If you are presenting the modal view from either of the two sub-views of the SplitViewController, then you will have the orientation problems. Just present the modal view from the SplitViewController.

Resources