在故事板中使用导航控制器作为rootviewcontroller。我希望在翻页时更新currentIndex。 Storyboard push segue正在显示这个pdfviewcontroller场景,我首先尝试显示标题。
- (void) displaycurrentIndex:(NSUInteger)currentIndex {
self.navigationItem.title = [NSString stringWithFormat:
@"Page %i of %i",
currentIndex,
CGPDFDocumentGetNumberOfPages(pdf)];
}
Pageviewcontroller其他类有数据源方法在pdfviewcontroller类中正向和反向显示pdf页面
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerBeforeViewController:(UIViewController *)viewController
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerAfterViewController:(UIViewController *)viewController
在pdfviewcontroller中尝试了这种方法但没有工作
- (void)updatecurrentpagenumber {
if (currentIndex == CGPDFDocumentGetNumberOfPages(pdf) - 1) {
[self displaycurrentIndex:currentIndex + 1];
}
//page = [modelArray objectAtIndex:currentIndex + 1];
else if (currentIndex == 0) {
[self displaycurrentIndex:currentIndex - 1];
}
//page = [modelArray objectAtIndex:currentIndex - 1];
}
编辑:
尝试了这一点,但仍然没有更新currentIndex
- (void)updatecurrentIndex:(NSUInteger)currentIndex {
totalPages = (int)CGPDFDocumentGetNumberOfPages(pdf);
if (currentIndex<totalPages -1)
{
[self displaycurrentIndex:currentIndex + 1];
}
else
{
[self displaycurrentIndex:currentIndex - 1];
}
感谢您的帮助。