2017-10-10 6 views
0

こんにちは。ページビューコントローラーがコード化されたスタイルに移行していません

トランジションスタイルは私のコードで

を.scrollするように設定されている場合PageControllerで=のViewController(transitionStyleてみましょう3ページからなる単純なページベースのアプリケーション、.pageTurnスタイルを使用してしかし、ビューコントローラの移行を作ります: .scroll、navigationOrientation:.horizo​​ntal、options:nil)

なぜ私はコード化したものに従わないのですか?

フルコード:

let pageController = ViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) 

class ViewController: UIPageViewController { 

// page view controllers here 
let cardsVC: UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "CardsNavController") 
let profileVC: UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ProfileNavController") 
let matchesVC: UIViewController! = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MatchesNavController") 

override func viewDidLoad() { 
    super.viewDidLoad() 

    view.backgroundColor = UIColor.white 
    dataSource = self 
    // loads first view 
    setViewControllers([profileVC], direction: .forward, animated: true, completion: nil) 
} 


// load left view 
func goToNextVC() { 
    let nextVC = pageViewController(self, viewControllerAfter: viewControllers![0])! 
    setViewControllers([nextVC], direction: .forward, animated: true, completion: nil) 
} 
// load right view 
func goToPreviousVC() { 
    let previousVC = pageViewController(self, viewControllerBefore: viewControllers![0])! 
    setViewControllers([previousVC], direction: .reverse, animated: true, completion: nil) 
} 

override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
    // Dispose of any resources that can be recreated. 
    } 


} 

// MARK - UIPageViewControllerDataSource 
extension ViewController: UIPageViewControllerDataSource { 

func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? { 

    // navigate right 
    switch viewController { 
    case cardsVC: 
     return profileVC 
    case profileVC: 
     return nil 
    case matchesVC: 
     return cardsVC 
    default: 
     return nil 
    } 
} 

// navigate left 
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? { 

    switch viewController { 
    case cardsVC: 
     return matchesVC 
    case profileVC: 
     return cardsVC 
    case matchesVC: 
     return nil 
    default: 
     return nil 
    } 
} 

}

答えて

0

このような用途:

required init?(coder: NSCoder) { 
    super.init(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) 
} 
0

には、次のプロジェクトを見てください、それはあなたを与えるだろう、私はここにcontainerViewを使用していた結果 を期待ページビューコントローラを使用しているtableViewsを持つViewController

ストーリーボード

スクリーンショット

enter image description here

出力 - enter image description here

関連する問題