swift tableview array 스위프트 테이블뷰
//
// MainViewController.swift
// TableViewAI
//
// Created by stayfoolish on 20/11/2018.
// Copyright © 2018 stayfoolish. All rights reserved.
//
import UIKit
class MainViewController: UIViewController, UITableViewDataSource {
@IBOutlet var tableView: UITableView!
let dataArray = ["1","2","3","4","5","6","7","8","9","10"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.tableView.dataSource = self
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "numberCell", for: indexPath)
cell.textLabel?.text = dataArray[indexPath.row]
return cell
}
}
'Swift > 기초&문법' 카테고리의 다른 글
swift tableview didselectrowat 스위프트 테이블뷰 선택하였을 때 (0) | 2018.11.13 |
---|---|
swift tableview custom 스위프트 테이블뷰 커스텀 (0) | 2018.11.12 |
swift tableview 간단한 스위프트 테이블뷰 , 디테일 뷰 (0) | 2018.11.10 |
swift tableview 간단한 테이블뷰 추가, 삭제 스위프트 (0) | 2018.11.08 |
MyWebBrowser swift 스위프트 웹브라우저 앱 (0) | 2018.11.07 |