UIPageViewController的setViewControllers方法,UIPageControl没有显示正确的当前页码。

7

我正在使用带有水平滚动的UIPageViewController...只要用户滚动,UIPageControl就能正常工作,当以编程方式跳转到下一个或上一个页面时会出现问题。

[self.pageViewController setViewControllers:@[[self viewControllerWithIndex:index]] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:nil];

UIPageControl的索引不正确(我本来想提供索引,但无法访问UIPageViewController的UIPageControl)。

- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController {
    return IntroScreensCount;
}

- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController {
    return 0;
}

如何在以编程方式更改UIPageViewController页面时正确获取UIPageControl的当前点索引?

1
展示你的委托方法。 - Jay Gajjar
编辑过了,但是委托并没有涉及到它,因为它们只提供最小和最大索引,而不是当前的索引。 - Peter Lapisu
好的,现在我明白了。 - Peter Lapisu
1个回答

10

好的,结果是我误解了一个委托方法。

- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController {
    return [(IntroPageViewController *)[pageViewController.viewControllers firstObject] index];
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接