2017-04-12 64 views
0

我有一个按钮,我只想转到下一页。转到下一页UIPageViewController

我已阅读其他线程人说,只是用这个,

setViewControllers([UIVIewController], direction: .forward, animated: false, completion: nil) 

我在上一个子视图按钮尝试这样做。我发现PageControl(小圆点)具有我想要的功能,但我似乎无法找到苹果如何实现这一点。我一直在阅读stackOverflow上的很多帖子,但我并没有完全理解它。

我有一个rootViewController实现dataSource和委托。

回答

1

首先得到current view controllernext view controller,然后通过下一个视图控制器setViewControllers功能

func moveToNextPage() { 

    guard let currentViewController = self.viewControllers?.first else { return print("Failed to get current view controller") } 

    guard let nextViewController = self.dataSource?.pageViewController(self, viewControllerAfter: currentViewController) else { return } 

    setViewControllers([nextViewController], direction: .forward, animated: false, completion: nil) 

} 

我希望这可以帮助你。