0

I have a page based application with two View Controllers.On clicking a button in ViewController1, I'm trying to move from ViewController1 to ViewController2.

Suppose, ViewController1 is of index 0 and ViewController2 is 1.This is what I'm trying to do on ViewController1.swift file.

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)
        }

code snippet from 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)
 }
confused human
  • 401
  • 8
  • 23
  • I understood you totally wrong. Your question is very messy but now I understand that you want to know how to make PageViewController(like slides)? – Tarvo Mäesepp Jun 23 '16 at 14:43
  • Yes, I wanna make PageViewController. From tutorials online, I've created one but I need a button on each view controllers that would on click take to respective next ViewController.Appreciate your help. – confused human Jun 23 '16 at 14:56

1 Answers1

0

There is a good tutorial that shows you how to do this. The next button transitions the page view to the next page.

https://github.com/jeffaburt/UIPageViewController-Post

onemillion
  • 682
  • 5
  • 19