custom TableViewCell 커스텀 테이블뷰셀 만들기, 테이블뷰 줄 안보이게 하기
//
// MainFeatureCell.swift
// ai 11
//
// Created by stayfoolish on 2018. 9. 20..
// Copyright © 2018년 stayfoolish. All rights reserved.
//
import UIKit
class MainFeatureCell: UITableViewCell {
@IBOutlet weak var featureImageView: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
}
//
// SampleData.swift
// ai 11
//
// Created by stayfoolish on 2018. 9. 20..
// Copyright © 2018년 stayfoolish. All rights reserved.
//
import Foundation
struct Sample {
let title: String
let desription: String
let image: String
}
struct SampleData {
let samples = [
Sample(title: "Photo Object Detection", desription: "불러온 이미지에 있는 사물 인식", image: "ic_photo"),
Sample(title: "Real Time Object Detection", desription: "실시간으로 카메라에 보이는 사물 인식", image: "ic_camera"),
Sample(title: "Facial Analysis", desription: "사람 얼굴로부터 나이, 성별, 감정 추측", image: "ic_emotion")
]
}
//
// MainViewController.swift
// ai 11
//
// Created by stayfoolish on 2018. 9. 20..
// Copyright © 2018년 stayfoolish. All rights reserved.
//
import UIKit
class MainViewController: UIViewController , UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
let sampleData = SampleData()
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.tableFooterView = UIView(frame: .zero)
self.tableView.dataSource = self
}
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
}
}
'Swift > 기초&문법' 카테고리의 다른 글
swift weather 날씨앱 로컬 딕셔너리 사용 스위프트 (0) | 2018.09.22 |
---|---|
swift tableView cell 선택했을 때 화면 이동 스위프트 테이블뷰 (1) | 2018.09.21 |
swift tableview 스위프트 테이블뷰 data array (0) | 2018.09.20 |
swift 스위프트 화면 이동 modal push (0) | 2018.09.19 |
스위프트 swift 인스턴스 생성 소멸 (0) | 2018.09.04 |