I have a UIPageViewController and I just can not figure out how to know to what direction the user turned the page so i can set the page count appropriately.
Thanks Shani
As Hejazi said
After a gesture-driven transition completes this delegate method is called:
pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted:
The part that should be clarified is that completed
will be YES
if the page was fully turned and will be NO
if the page did not actually turn. The NO
case happens, for example, when the user just pulls up the corner of the page and then puts it back down without flipping the page.
This is the concept you will want to implement:
- (void)pageViewController:(UIPageViewController *)pvc didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed
{
// If the page did not turn
if (!completed)
{
// You do nothing because whatever page you thought
// the book was on before the gesture started is still the correct page
return;
}
// This is where you would know the page number changed and handle it appropriately
// [self sendPageChangeNotification:YES];
}
After a gesture-driven transition completes this delegate method is called:
pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted:
So by comparing the previousViewControllers
parameter and pageViewController.viewControllers
you can know the direction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With