Swift 教程之笔记App02配置tableviewcontr
2019-05-18 本文已影响4人
iCloudEnd
Swift 教程之笔记App02配置tableviewcontroller
步骤
- 设置UITableViewController
class FoldersController: UITableViewController {
- 定义一个cell id
fileprivate let CELL_ID:String = "CELL_ID"
- 注册cell id
fileprivate func setupTableView() {
tableView.register(UITableViewCell.self, forCellReuseIdentifier:CELL_ID)
}
- 设置行数和每行的cell
extension FoldersController {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: CELL_ID, for: indexPath)
cell.textLabel?.text = "here's a note folder"
return cell
}
}
运行效果
