我正在尝试使用100010000001000000000101000000011
在auto sliding
中创建page view controller
。在这里,我尝试使用下面的代码,但得到结果,它正在重复图像的第一个swift 4
。我需要知道,如何实现下一个索引的移动?
index
答案 0 :(得分:0)
// Image array
var name = ["one.png","two.png","three.png","four.png"]
var currentIndex = -1
// Timer in viewdidload()
tTime = Timer.scheduledTimer(timeInterval: 4, target: self, selector: #selector(changeSlide), userInfo: nil, repeats: true)
// Timer function call
@objc func changeSlide()
{
currentIndex = (currentIndex == name.count - 1) ? 0 : currentIndex + 1
let pageContentViewController = self.viewControllerAtIndex(index: currentIndex)
self.pageViewController.setViewControllers([pageContentViewController!], direction: UIPageViewControllerNavigationDirection.forward, animated: true, completion: nil)
}