Created
May 21, 2017 07:34
-
-
Save hikui/e198e7229b3634eb4a79111625efc319 to your computer and use it in GitHub Desktop.
Shell View Controller for a New App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ShellViewController.swift | |
// Danta-iOS-App | |
// | |
// Created by Henry Heguang Miao on 21/5/17. | |
// Copyright © 2017 Henry Miao. All rights reserved. | |
// | |
import UIKit | |
class AppShellController: UITableViewController { | |
let array = [ | |
"1. Free Experiment", | |
] | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Default background color is ASF's white | |
view.backgroundColor = UIColor.white | |
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") | |
// App Version | |
setupAppVersion() | |
} | |
override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
// Page Title | |
title = "App Shell" | |
} | |
override func viewDidDisappear(_ animated: Bool) { | |
super.viewDidAppear(animated) | |
title = nil | |
} | |
func setupAppVersion() { | |
// Show current version | |
let label = UILabel(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 44)) | |
label.textAlignment = .center | |
label.text = AppUtilities.versionString() | |
tableView.tableFooterView = label | |
} | |
// MARK: - Table view data source | |
override func numberOfSections(in tableView: UITableView) -> Int { | |
// #warning Incomplete implementation, return the number of sections | |
return 1 | |
} | |
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
// #warning Incomplete implementation, return the number of rows | |
return array.count | |
} | |
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) | |
cell.textLabel?.text = array[indexPath.row] | |
cell.accessoryType = .disclosureIndicator | |
return cell | |
} | |
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
switch indexPath.row { | |
case 0: // Free experiment | |
break | |
default: break | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment