我希望能够使用 UIPageViewController
来跟踪索引。每当我滑动时,我需要执行 index++
或者 index--
操作。下面这个委托方法会在你向前或向后滑动时被调用:
- (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;
}
// I want to check here whenever the page was swiped back or further
}
如何在该方法中检查用户是否向后或向前滑动?我知道有两个数据源方法“viewControllerAfterViewController”和“viewControllerBeforeViewController”,但我无法检查页面转换是否已完成(而我可以在上述方法中执行此操作),有什么想法,我如何知道用户在上述方法中向后滑动还是向前滑动?
nextIndex
应该等于currentIndex + 1
。在didFinishAnimating
中,检查新的currentIndex == nextIndex
,如果是向左滑动,则为左滑,否则为右滑。 - huync