將UIPageViewControllerSpineLocation設置爲.mid我正在創建將用於研究各種術語的iPhone flashcard應用程序。目前,我正在使用UIPageViewController來顯示每個連續的卡(視圖控制器)。當用戶點擊一張卡片時,它將翻轉並向後顯示它們,當它們向左或向右滑動時,它們可以在卡片之間滾動。 Current App interface如何使用transitionStyle .scroll
到目前爲止,這項工作很好,但我希望能夠在橫向顯示卡的正面和背面。通常,使用UIPageViewControllerDelegate的方法func pageViewController(_ pageViewController: UIPageViewController, spineLocationFor orientation: UIInterfaceOrientation)
並返回.mid
(如果方向是水平的)很容易。但是,因爲我沒有使用.pageCurl
而是.scroll
作爲我的pageViewController的transitionStyle,所以此方法從不會被調用。 Apple Documentation不使用.pageCurl
時也不能手動設置。蘋果的文件說:
A spine location is only valid if the transition style is pageCurl. If the transition style is pageCurl, the default value for this property is min; otherwise, the default is none.
我試圖添加一個方法被調用時的方向是橫向:
func showBothSides(){
let currentViewController = self.pageViewController!.viewControllers![0] as! PracticePageDataVC
let viewControllers: [UIViewController] = [currentViewController, currentViewController]
self.pageViewController!.setViewControllers(viewControllers, direction: .forward, animated: true, completion: {done in })
}
但這返回錯誤:「'提供的視圖控制器的數量(2)不符合要求的數量(1)所需的過渡'「
因此,基本上我正在尋找一種替代解決方案來並排顯示兩個視圖控制器,同時仍然保持hor卡片之間的橫向滾動轉換。
謝謝!我害怕這個......但我想知道/希望有一個快速和簡單的解決方案。感謝幫助! –
請注意,這些方法都不會給你某種神奇的半尺寸頁面滾動。頁面的大小是滾動視圖的大小。 – matt