1

在故事板中使用导航控制器作为 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];
}

感谢帮助。

4

0 回答 0