在过去的几天里,我一直在努力解决这个问题,经过所有这些杂耍之后,我发现我所需要的只是数据源方法中的当前索引,以使用当前可见页码进行更新
我有这个UIPageViewController
数据源方法,我需要使用当前索引来获取委托方法的当前可见页面previousViewControllers transitionCompleted:(BOOL)completed
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerAfterViewController:(UIViewController *)viewController {
NSString *path = [[NSBundle mainBundle] pathForResource:@"pages" ofType:@"pdf"];
NSURL *pdfurl = [NSURL fileURLWithPath:path];
PDFDocument = CGPDFDocumentCreateWithURL((__bridge CFURLRef)pdfurl);
contentViewController = [[ContentViewController alloc] initWithPDFAtPath:path];
currentIndex = [modelArray indexOfObject:[(ContentViewController *)viewController page]];
if (currentIndex == totalPages - 1) {
return nil;
}
contentViewController.page = [modelArray objectAtIndex:currentIndex + 1];
return contentViewController;
}
我对如何将当前索引语句从数据源方法写入委托方法以更新当前可见页面感到困惑。
- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed{
if (!completed)
{
return;
}
//currentIndex = [[self.pageViewController.viewController lastObject]];
currentIndex = [self indexOfObject:contentViewController];
[self displaycurrentIndex:currentIndex];
//self.pageControl.currentPage = currentIndex;
}
我该如何纠正?