//
// MainViewController.swift
// ai 11
//
// Created by stayfoolish on 2018. 9. 20..
// Copyright © 2018년 stayfoolish. All rights reserved.
//
import UIKit
class MainViewController: UIViewController , UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
let sampleData = SampleData()
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.tableFooterView = UIView(frame: .zero)
self.tableView.dataSource = self
self.tableView.delegate = self
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.prefersLargeTitles = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.navigationBar.prefersLargeTitles = false
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.sampleData.samples.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "mainFeatureCell", for: indexPath) as! MainFeatureCell
let sample = self.sampleData.samples[indexPath.row]
cell.titleLabel.text = sample.title
cell.descriptionLabel.text = sample.desription
cell.featureImageView.image = UIImage(named: sample.image)
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
switch indexPath.row {
case 0: self.performSegue(withIdentifier: "photoObjectDetection", sender: nil)
case 1: self.performSegue(withIdentifier: "realTimeObjectDetection", sender: nil)
case 2: self.performSegue(withIdentifier: "facialAnalysis", sender: nil)
default:
return
}
}
}
'Swift > 기초&문법' 카테고리의 다른 글
스위프트 옵셔널 체이닝과 nil 병합 swift optional (0) | 2018.09.23 |
---|---|
swift weather 날씨앱 로컬 딕셔너리 사용 스위프트 (0) | 2018.09.22 |
swift custom tableview 스위프트 커스텀 테이블뷰 (0) | 2018.09.20 |
swift tableview 스위프트 테이블뷰 data array (0) | 2018.09.20 |
swift 스위프트 화면 이동 modal push (0) | 2018.09.19 |