ListViewController.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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?.registerClass(UITableViewCell.self, forCellReuseIdentifier: kCellIdentifier)
  17. }
  18. override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
  19. let cell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier)! as UITableViewCell
  20. cell.textLabel?.text = demos[indexPath.row]
  21. return cell
  22. }
  23. override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  24. return demos.count
  25. }
  26. override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  27. if indexPath.row == 0 {
  28. let viewController = SimpleLayoutViewController()
  29. navigationController?.pushViewController(viewController, animated: true)
  30. } else if indexPath.row == 1 {
  31. let viewController = BasicUIScrollViewController()
  32. navigationController?.pushViewController(viewController, animated: true)
  33. }
  34. }
  35. }