我希望在更改 UIViewController
的方向时更改 UIPageViewController
的导航方向。也就是说,当设备旋转到纵向时,我希望 navigationOrientation
从 UIPageViewControllerNavigationOrientationVertical
更改为 UIPageViewControllerNavigationOrientationHorizontal
。
我尝试在 View Controller 旋转时设置 navigationOrientation
属性,但我发现 navigationOrientation
属性是只读的。
这是我想要的图片。
横向 View
纵向 View
我该怎么办?
最佳答案
好问题。
不知道为什么,但似乎 Apple 不希望您更改该属性。技术原因或某种 UI 指南。
无论如何,如果您不能更改方向,您应该采用不同的方法并使用两个 UIPageViewControllers
,每个都有另一个导航方向,它们共享一个委托(delegate)。在设备转动时隐藏/显示相应的 View ,或者在每次设备转动时初始化/释放一个新对象。
顺便说一句。您是否看过委托(delegate)的 pageViewController:spineLocationForInterfaceOrientation:
方法。似乎 Apple 对设备方向变化使用react的首选方式是这种方式:
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
.
请注意,Apple 的日历应用程序的纵向页面非常纤细 - 似乎确实是他们的 UI 理念。
关于iphone - iPad : UIPageViewController navigationOrientation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10430083/