Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad : UIPageViewController navigationOrientation

I want the navigationOrientation of my UIPageViewController to change when I change the orientation of my UIViewController. That is, when the device is rotated to portrait I want the navigationOrientation to change from UIPageViewControllerNavigationOrientationVertical to UIPageViewControllerNavigationOrientationHorizontal.

I tried setting navigationOrientation property on rotation of the view controller but I found that navigationOrientation property is read-only.

Here are the images what I want.

Landscape View Landscape View

Portrait View enter image description here

What should I do ?

like image 933
Devang Avatar asked May 03 '12 11:05

Devang


People also ask

How do I navigate from page to page in uipageviewcontroller?

When navigating from page to page, the page view controller uses the transition that you specify to animate the change. In tvOS, the UIPageViewController class provides only a way to swipe between full-screen content pages.

How do I programmatically navigate from page to page in iOS?

Page view controller–navigation can be controlled programmatically by your app or directly by the user using gestures. When navigating from page to page, the page view controller uses the transition that you specify to animate the change. In tvOS, the UIPageViewController class provides only a way to swipe between full-screen content pages.

What is uipageviewcontroller in Salesforce?

The UIPageViewController class highlights the distinction between a view controller and a container controller. The container controller is used to contain and manage multiple view controllers shown in the app, as well as, controlling the way one view controller switches to another.

What is the uipageviewcontrollerdelegate protocol?

The delegate of a page view controller must adopt the UIPageViewControllerDelegate protocol. These methods allow the delegate to receive a notification when the device orientation changes and when the user navigates to a new page.


1 Answers

Good question.

Don't know why, but it seems as if Apple doesn't want you to change that property. Either technical reasons or some sort of UI-guideline.

Anyway if you cannot change the orientation you should go with a different approach and use two UIPageViewControllers, each with another navigation orientation, which share one delegate. On device turn you hide/show the corresponding views or you init/release a new object each device turn.

BTW. Did you have a look at the pageViewController:spineLocationForInterfaceOrientation: method of the delegate. Seems as if Apple's preferred way of reacting to device orientation changes is this one:

Discussion Use this method to change the spine location when the device orientation changes, as well as setting new view controllers and changing the double-sided state.

This method is called only if the transition style is UIPageViewControllerTransitionStylePageCurl.

Note that Apple's calendar app goes with very slim pages in portrait - seems really to be their idea of UI.

like image 89
Kai Huppmann Avatar answered Oct 20 '22 05:10

Kai Huppmann