我有一个带有两个View Controllers的基于页面的应用程序。点击ViewController1中的一个按钮,我试图从ViewController1移动到ViewController2。
假设,ViewController1的索引为0,ViewController2为1.这就是我在ViewController1.swift文件中尝试做的事情。
var viewCont = MyPageViewController()
viewCont.arrayViewControllers[1] (getting next ViewController from array declared in PageViewController file)
scrollToViewController(viewCont.arrayViewControllers[1], direction: .Forward)
func scrollToViewController(viewController: UIViewController,
direction: UIPageViewControllerNavigationDirection = .Forward) {
viewCont.setViewControllers([viewController],
direction: direction,
animated: false,
completion: { (finished) -> Void in
})
viewCont.tutorialDelegate?.tutorialPageViewController(viewCont,
didUpdatePageIndex: 1)
}
来自myPageViewController的代码片段
protocol TutorialPageViewControllerDelegate: class {
/**
Called when the current index is updated.
- parameter myPageViewController: the MyPageViewController instance
- parameter index: the index of the currently visible page.
*/
func tutorialPageViewController(tutorialPageViewController: TutorialPageViewController,
didUpdatePageIndex index: Int)
}
答案 0 :(得分:0)
有一个很好的教程可以告诉你如何做到这一点。下一个按钮将页面视图转换到下一页。