-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmenu.swift
More file actions
67 lines (52 loc) · 2.06 KB
/
menu.swift
File metadata and controls
67 lines (52 loc) · 2.06 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
//
// menu.swift
// dda-tap
//
// Created by Victor Sira on 2019-10-27.
// Copyright © 2019 Code the Change. All rights reserved.
//
import UIKit
class menu: UITableViewController {
// MARK: Properties
var menuLabels = ["Add picture and recording", "Instructions", "TAP guide"]
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return menuLabels.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellIdentifier = "MenuCell"
guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as? MenuOption
else {
fatalError("The dequeued cell is not an instance of MenuOption.")
}
// Fetches the appropriate menuOption for the data source layout
let label = menuLabels[indexPath.row]
cell.nameLabel.text = label
return cell
}
// MARK: Private Methods
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let segueIdentifier: String
switch indexPath.row {
case 0:
segueIdentifier = "showAddMainEntries"
case 1:
segueIdentifier = "showInstructions"
case 2:
segueIdentifier = "showTAPGuide"
default:
segueIdentifier = "showAddMainEntries"
}
self.performSegue(withIdentifier: segueIdentifier, sender: self)
}
}