I want to get current index of a pageViewController, I don't know how I get the visible pages index.
func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool,previousViewControllers: [UIViewController],transitionCompleted completed: Bool)
{
// How to get it?
}
Dont forget to set pageviewcontroller's delegate.
In Swift 3
Override didFinishAnimating function of UIPageViewControllerDelegate like this:
where WalkthroughContentViewController is the UIViewController presented by UIPageViewController
Remember to keep an index variable inside the WalkthroughContentViewController. Also, in the viewDidLoad method set:
Swift 3: full programmatic PageViewController example to get/set the current page index without view tagging:
UIPageViewController DataSource implementation:
Try it..
You can use next method:
Where tutorialViews is an array of pages (ViewControllers).
And initialize currentIndex like that:
You can use didFinishAnimating, and set tags to viewcontrollers. try this