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
Portrait View
What should I do ?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With