-
Notifications
You must be signed in to change notification settings - Fork 0
/
SportsTableViewController.swift
90 lines (60 loc) · 2.48 KB
/
SportsTableViewController.swift
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// SportsTableViewController.swift
// StatSheet
//
// Created by Sampath Duddu on 12/31/14.
// Copyright (c) 2014 NexGenTec. All rights reserved.
//
import UIKit
class SportsTableViewController: UITableViewController, UITableViewDelegate {
var sports = ["NBA", "NFL", "MLB", "NHL"]
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.contentInset = UIEdgeInsetsMake(20.0, 0.0, 0.0, 0.0);
// 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()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return sports.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell")
cell.textLabel?.text = sports[indexPath.row]
cell.accessoryType = .DisclosureIndicator
return cell
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//CODE TO BE RUN ON CELL TOUCH
if indexPath.row == 0
{
performSegueWithIdentifier("NBAsegue", sender: nil)
}
else if indexPath.row == 1
{
performSegueWithIdentifier("NFLsegue", sender: nil)
}
else if indexPath.row == 2
{
performSegueWithIdentifier("MLBsegue", sender: nil)
}
else if indexPath.row == 3
{
performSegueWithIdentifier("NHLsegue", sender: nil)
}
}
}