mirror of https://github.com/xaoxuu/ProHUD
56 lines
1.4 KiB
Swift
56 lines
1.4 KiB
Swift
//
|
|
// BaseListVC.swift
|
|
// Example
|
|
//
|
|
// Created by xaoxuu on 2019/8/12.
|
|
// Copyright © 2019 Titan Studio. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class BaseListVC: UIViewController {
|
|
|
|
lazy var tableView: UITableView = {
|
|
let tv = UITableView()
|
|
|
|
return tv
|
|
}()
|
|
|
|
var titles: [String] {
|
|
return ["Toast", "Alert", "Guard"]
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
|
|
view.addSubview(tableView)
|
|
tableView.dataSource = self
|
|
tableView.delegate = self
|
|
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
|
|
tableView.snp.makeConstraints { (mk) in
|
|
mk.edges.equalToSuperview()
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
extension BaseListVC: UITableViewDataSource, UITableViewDelegate {
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
return titles.count
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
|
|
cell.textLabel?.text = titles[indexPath.row]
|
|
return cell
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
tableView.deselectRow(at: indexPath, animated: true)
|
|
}
|
|
|
|
}
|