Swift iOS: how to trigger next page using buttons

后端 未结 6 1165
醉话见心
醉话见心 2020-12-15 11:56

I have a QuizViewController which extends UIViewController, UIPageControllerDelegate, and a UIPageView

6条回答
  •  感动是毒
    2020-12-15 12:12

    You can use this function:

    func movePageToIndex(pageIndex NSInteger)->() {
        var viewControllers = []
        var direction : UIPageViewControllerNavigationDirection! 
        if (pageIndex < currentIndex) {
            direction = UIPageViewControllerNavigationDirection.Reverse
        } else {
            direction = UIPageViewControllerNavigationDirection.Forward
        }
        viewControllers = @[[self.getItemController(pageIndex)]]
    
        WEAKSELF weakSelf = self;
        self.pageViewController.setViewControllers:viewControllers direction:direction animated:false completion:nil];
    }
    

提交回复
热议问题