本文介绍了UIPageViewController setViewController,UIPageControl不显示正确的当前数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用UIPageViewController水平滚动...只要用户滚动,UIPageControl工作正常,以编程方式跳到下一页或上一页时出现问题
I'am using a UIPageViewController with horizontal scrolling... as long as the user scrolls, the UIPageControl works correctly, problem occurs when jumping programmatically to next or previous page
[self.pageViewController setViewControllers:@[[self viewControllerWithIndex:index]] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:nil];
由于UIPageControl的索引不正确(我会自己提供索引,访问UIPageViewController的UIPageControl)
Than the index of the UIPageControl isn't right (i would provide the index by myself, but cannot access the UIPageViewController's UIPageControl)
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController {
return IntroScreensCount;
}
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController {
return 0;
}
如何获取UIPageControl的当前点索引以编程方式更改UIPageViewController页面?
推荐答案
ok,结果是我误解了一个委托方法
ok, turned out that i misunderstood one delegate method
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController {
return [(IntroPageViewController *)[pageViewController.viewControllers firstObject] index];
}
这篇关于UIPageViewController setViewController,UIPageControl不显示正确的当前数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!