UIPageViewController setViewControllers, UIPageControl not showing the correct current number

I use the UIPageViewController with horizontal scrolling ... while the user scrolls, the UIPageControl is working correctly, there is a problem when programming programmatically on the next or previous page

[self.pageViewController setViewControllers:@[[self viewControllerWithIndex:index]] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:nil]; 

Than the UIPageControl index is wrong (I would have provided the index myself, but could not access the UIPageViewController UIPageControl)

 - (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController { return IntroScreensCount; } - (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController { return 0; } 

How to get the current UIPageControl access point index when changing the UIPageViewController page programmatically?

+7
ios cocoa-touch uipageviewcontroller uipagecontrol
source share
1 answer

ok, it turned out that I misunderstood one delegate method

 - (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController { return [(IntroPageViewController *)[pageViewController.viewControllers firstObject] index]; } 
+10
source share

All Articles