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

    }

    



}



+ Recent posts