개발언어/Swift
스위프트 뉴스앱 만들기1(table view)
우주먼지쪼가리
2021. 10. 13. 20:00
반응형
//
// ViewController.swift
// newsApp
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableViewMain: UITableView!
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
//몇개? 숫자
return 10
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
//무엇? 반복 10번?
//1. 임의의 셀 만들기
let cell = UITableViewCell.init(style: .default, reuseIdentifier: "TableCellType")
cell.textLabel?.text = "\(indexPath.row)"
return cell
}
override func viewDidLoad() {
super.viewDidLoad()
//self : class viewcontroller 안의 func들을 의미함.
tableViewMain.delegate = self
tableViewMain.dataSource = self
}
//tableview : 테이블로 된 뷰 - 여러개의 행이 모여있는 화면 목록
//1. 데이터 무엇?
//2. 데이터 몇개?
}
by 유투버 센치한 개발자
반응형