user11497206
user11497206

Reputation:

UIPageControl of a UIPageViewController sometimes does not get updated when it is scrolled to next view controller

I have created a subclass of UIPageViewController with transitionStyle = .scroll and have implemented the UIPageViewControllerDataSource methods that are responsible for showing the UIPageControl as follows-

func presentationCount(for pageViewController: UIPageViewController) -> Int {
    return 3
}

func presentationIndex(for pageViewController: UIPageViewController) -> Int {
    return 0
}

The page view controller has modalPresentationStyle of .custom such that when the view controller is presented it does not occupy fullscreen.

I have observed sometimes when I scroll the page view controller to show the next child view controller, the page indicator is not updated. The following GIF shows the problem

Can anyone point out how to resolve this issue?

Upvotes: 0

Views: 78

Answers (1)

Mitul.Patel
Mitul.Patel

Reputation: 252

Please use the below method for the page change acknowledgement.

  func pageViewController(_ pageViewController: UIPageViewController, 
 didFinishAnimating finished: Bool, previousViewControllers: 
 [UIViewController], transitionCompleted completed: Bool) {

    pageControl.currentPage = arrViewController.index(of: pageContentViewController) ?? 0

}

Upvotes: 1

Related Questions