I want to use a UISlider
control to manage UIPageViewController
pagination. I have managed getting the number of pages, and those are the values that the slider uses to scroll
the pagination.
Now, it is working. The problem comes when I change the value so quickly. Anyone knows how can I solve this point?
- (void)changeValueSlider:(UISlider *)slider {
[self goToPageAtIndex:slider.value];
}
- (void)goToPageAtIndex:(NSUInteger)index {
MNBBasePreviewViewController *currentViewController = self.pageViewController.viewControllers.firstObject;
if (index < self.previewContainerInteractor.count){
if (index < currentViewController.index) {
[self backToPageAtIndex:index];
} else if (index > currentViewController.index) {
[self forwardToPageAtIndex:index];
}
}
}
- (void)forwardToPageAtIndex:(NSUInteger)index {
MNBBasePreviewViewController *previewViewController = [self viewControllerAtIndex:index];
[self.pageViewController setViewControllers:@[previewViewController] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
}
- (void)backToPageAtIndex:(NSUInteger)index {
MNBBasePreviewViewController *previewViewController = [self viewControllerAtIndex:index];
[self.pageViewController setViewControllers:@[previewViewController] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:NULL];
}