本文介绍了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当前页面索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!