-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserViewController.swift
More file actions
69 lines (50 loc) · 1.73 KB
/
UserViewController.swift
File metadata and controls
69 lines (50 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// UserViewController.swift
// AutoLayoutAnimation
//
// Created by Ozgur Vatansever on 10/27/15.
// Copyright © 2015 Techshed. All rights reserved.
//
import UIKit
class UserViewController: UITableViewController {
var user: User!
fileprivate static let CellIdentifier = "UserCell"
var info = [String]() {
didSet {
tableView.reloadData()
}
}
convenience init() {
self.init(nibName: "UserViewController", bundle: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
edgesForExtendedLayout = UIRectEdge()
tableView.tableFooterView = UIView(frame: CGRect.zero)
tableView.register(UITableViewCell.self, forCellReuseIdentifier: UserViewController.CellIdentifier)
title = user.firstName
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
execute(delay: 2.0, repeating: false) {
self.info = [self.user.fullName, String(self.user.userId), self.user.city]
}
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return info.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: UserViewController.CellIdentifier)!
cell.textLabel?.text = info[indexPath.row]
cell.selectionStyle = .gray
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
}