Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- IOS
- 포켓볼
- Xcode
- Check
- 신도림
- 해몽
- error
- UITableView
- afterdelay
- UIView
- 앱스토어
- 샘플
- 포켓몬 GO
- Bitcode
- 아이폰7
- 보라카이
- Example
- 공략
- 신도림 테크노마트
- push
- LG유플러스
- 스마트폰
- swift
- 페이백
- setting
- loop
- swift3
- 얻는법
- GCD
- simulator
Archives
- Today
- Total
도래울
swift UITableView 예제 본문
In Swift there are no separate header and implementation files, the whole View Controller class is defined in the ViewController.swift file. Go to this file and right after the class ViewController: UIViewController { line add a constant containing some data for the table rows.
let tableData = ["One","Two",Three"]
Swift has inferred the constant as an Array of Strings. Next, set the number of rows in the tableView:numberOfRowsInSection function. Add this function before the closing bracket of the class.
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { return self.tableData.count; }
Our Table View will have 3 rows according to the count method of the Array class. Note in Swift a class method is called using the dot syntax. Next, implement the tableView:cellForRowAtIndexPath function
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { let cell:UITableViewCell = UITableViewCell(style:UITableViewCellStyle.Default, reuseIdentifier:"cell") cell.textLabel?.text = tableData[indexPath.row] return cell }
'개발 > iOS' 카테고리의 다른 글
UIScrollview Delegate 종류 (0) | 2016.04.22 |
---|---|
swift ActionSheet 예제 (0) | 2016.04.21 |
아이튠즈 커넥트 앱 상태 정보 (0) | 2016.04.15 |
Xcode 플러그인 관리툴 – Alcatraz Package Manager (0) | 2016.04.12 |
swift network library alamofire (1) | 2016.04.07 |
Comments