gpt4 book ai didi

ios - UIPageViewController setViewControllers,UIPageControl 未显示正确的当前编号

转载 作者:可可西里 更新时间:2023-11-01 03:29:07 27 4
gpt4 key购买 nike

我正在使用具有水平滚动功能的 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 的当前点索引?

最佳答案

好的,原来我误解了一个委托(delegate)方法

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

关于ios - UIPageViewController setViewControllers,UIPageControl 未显示正确的当前编号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21406833/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com