forked from teodorpatras/SideMenuController
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuController.swift
More file actions
44 lines (33 loc) · 1.37 KB
/
MenuController.swift
File metadata and controls
44 lines (33 loc) · 1.37 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
//
// MenuController.swift
// Example
//
// Created by Teodor Patras on 16/06/16.
// Copyright © 2016 teodorpatras. All rights reserved.
//
import UIKit
class MenuController: UITableViewController {
let segues = ["showCenterController1", "showCenterController2", "showCenterController3"]
private var previousIndex: NSIndexPath?
override func viewDidLoad() {
super.viewDidLoad()
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return segues.count
}
override func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "menuCell")!
cell.textLabel?.font = UIFont(name: "HelveticaNeue-Light", size: 15)
cell.textLabel?.text = "Switch to controller \(indexPath.row + 1)"
return cell
}
override func tableView(_ tableView: UITableView,
didSelectRowAt indexPath: IndexPath) {
if let index = previousIndex {
tableView.deselectRow(at: index as IndexPath, animated: true)
}
sideMenuController?.performSegue(withIdentifier: segues[indexPath.row], sender: nil)
previousIndex = indexPath as NSIndexPath?
}
}