I'm trying to have the UIPageViewController
navigate through the pages for every 5 seconds. How to do this in Swift?
Is there any way to explicitly call viewControllerAfterViewController
?
var timer = NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: Selector("update"), userInfo: nil, repeats: true)
func update() -> UIViewController {
// can u please tell me what to add here
}
func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController?
{
var index = (viewController as tourViewControllerhelper).pageIndex
if (index == 0) || (index == NSNotFound) {
return viewControllerAtIndex(4)
}
index--
pageCounter--
return viewControllerAtIndex(index)
}
func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController?
{
var index = (viewController as tourViewControllerhelper).pageIndex
if (index == NSNotFound || index == 4) {
return viewControllerAtIndex(0)
}
index++
pageCounter++
return viewControllerAtIndex(index)
}
func viewControllerAtIndex(index: Int) -> tourViewControllerhelper?
{
if self.pageTitles == 0 || index >= self.pageTitles
{
return nil
}
// Create a new view controller and pass suitable data.
let pageContentViewController = tourViewControllerhelper()
pageContentViewController.titleText = tourTextDescription[index]
pageContentViewController.pageIndex = index
currentIndex = index
println("xyz")
return pageContentViewController
}