基于块的 TableView,用于替换 UITableView 的委托和数据源,以获得更短的代码和更易于使用的代码
NKTableView
基于块的 TableView,用于替换 UITableView 的委托和数据源,以获得更短的代码和更易于使用的代码
let tableView = NKTableView(frame: .zero, style: .plain)
tableView.tableDataSource
.numberOfRowsInSection { section in 1 }
.cellForRowAt { tableView, indexPath in tableView.dequeueReusableCell(withIdentifier: "cell") ?? UITableViewCell(style: .default, reuseIdentifier: "cell") }
tableView.tableDelegate
.willDisplayCell { cell, indexPath in configCell(cell) }
.didSelectRowAt { indexPath in showDetails(indexPath) }
.heightForRowAt { indexPath in 50.0 }