本文介绍了Swift 中的 PageViewController 当前页面索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获取 pageViewController 的当前索引,我不知道如何获取可见页面索引.
I want to get current index of a pageViewController, I don't know how I get the visible pages index.
func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool,previousViewControllers: [UIViewController],transitionCompleted completed: Bool)
{
// How to get it?
}
推荐答案
您可以使用 didFinishAnimating,并为 viewcontrollers 设置标签.试试这个
You can use didFinishAnimating, and set tags to viewcontrollers. try this
func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool)
{
if (!completed)
{
return
}
self.pageControl.currentPageIndex = pageViewController.viewControllers!.first!.view.tag //Page Index
}
这篇关于Swift 中的 PageViewController 当前页面索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!