SnapKit/Example-iOS/ListViewController.swift

47 lines
1.5 KiB
Swift
Raw Normal View History

2016-03-01 17:58:06 +08:00
//
// ViewController.swift
// Example-iOS
//
// Created by Spiros Gerokostas on 01/03/16.
// Copyright © 2016 SnapKit Team. All rights reserved.
//
import UIKit
import SnapKit
2016-03-01 18:14:50 +08:00
class ListViewController: UITableViewController {
2016-03-01 17:58:06 +08:00
2016-03-01 18:14:50 +08:00
let kCellIdentifier = "CellIdentifier"
2016-03-01 19:13:24 +08:00
let demos = ["Simple Layout", "Basic UIScrollView"]
2016-03-01 17:58:06 +08:00
override func viewDidLoad() {
super.viewDidLoad()
self.title = "SnapKit iOS Demos"
2016-03-01 18:14:50 +08:00
self.tableView?.register(UITableViewCell.self, forCellReuseIdentifier: kCellIdentifier)
2016-03-01 17:58:06 +08:00
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return demos.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: kCellIdentifier)! as UITableViewCell
2016-03-01 18:14:50 +08:00
cell.textLabel?.text = demos[indexPath.row]
return cell
}
2016-03-01 17:58:06 +08:00
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
2016-03-01 18:14:50 +08:00
if indexPath.row == 0 {
2016-03-01 19:13:24 +08:00
let viewController = SimpleLayoutViewController()
navigationController?.pushViewController(viewController, animated: true)
} else if indexPath.row == 1 {
let viewController = BasicUIScrollViewController()
2016-03-01 18:14:50 +08:00
navigationController?.pushViewController(viewController, animated: true)
}
}
}