ListViewController.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // ViewController.swift
  3. // Example-iOS
  4. //
  5. // Created by Spiros Gerokostas on 01/03/16.
  6. // Copyright © 2016 SnapKit Team. All rights reserved.
  7. //
  8. import UIKit
  9. import SnapKit
  10. class ListViewController: UITableViewController {
  11. let kCellIdentifier = "CellIdentifier"
  12. let demos = ["Simple Layout", "Basic UIScrollView"]
  13. override func viewDidLoad() {
  14. super.viewDidLoad()
  15. self.title = "SnapKit iOS Demos"
  16. self.tableView?.register(UITableViewCell.self, forCellReuseIdentifier: kCellIdentifier)
  17. }
  18. override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  19. return demos.count
  20. }
  21. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  22. let cell = tableView.dequeueReusableCell(withIdentifier: kCellIdentifier)! as UITableViewCell
  23. cell.textLabel?.text = demos[indexPath.row]
  24. return cell
  25. }
  26. override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  27. if indexPath.row == 0 {
  28. let viewController = SimpleLayoutViewController()
  29. navigationController?.pushViewController(viewController, animated: true)
  30. } else if indexPath.row == 1 {
  31. let viewController = ViewController()
  32. navigationController?.pushViewController(viewController, animated: true)
  33. }
  34. }
  35. }