No Description

IntroductionViewController.swift 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // IntroductionViewController.swift
  3. // EncuestaMarle
  4. //
  5. // Created by Tatiana Castro on 5/21/19.
  6. // Copyright © 2019 Marle. All rights reserved.
  7. //
  8. import UIKit
  9. class IntroductionViewController: UIPageViewController, UIPageViewControllerDataSource {
  10. let pageViewControllers: [UIViewController] = {
  11. let introOne = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "introOneViewController")
  12. let introThree = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "introThreeViewController")
  13. return [introOne, introThree]
  14. }()
  15. override func viewDidLoad() {
  16. super.viewDidLoad()
  17. dataSource = self
  18. setViewControllers([pageViewControllers[0]], direction: .forward, animated: false, completion: nil)
  19. }
  20. func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
  21. let index = pageViewControllers.index(of: viewController)!
  22. if index - 1 >= 0 {
  23. return pageViewControllers[index - 1]
  24. }
  25. return nil
  26. }
  27. func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
  28. let index = pageViewControllers.index(of: viewController)!
  29. if index + 1 < pageViewControllers.count {
  30. return pageViewControllers[index + 1]
  31. }
  32. return nil
  33. }
  34. func presentationCount(for pageViewController: UIPageViewController) -> Int {
  35. return pageViewControllers.count
  36. }
  37. func presentationIndex(for pageViewController: UIPageViewController) -> Int {
  38. return 0
  39. }
  40. }