Class
TableView.DataSource
open class DataSource:NSObject, UITableViewDataSource, UITableViewDelegate
代理和数据源 如果想自定义或者实现UITableViewDataSource|UITableViewDelegate
其他协议方法 请继承重写
Relationships
Member Of
TableView
一个表格的数据源 可以快速搭建基于
UITableView
的列表或者复杂的UI界面,支持高度自动计算,自动缓存高度,便捷的高度刷新。
Conforms To
NSObject
UITableViewDataSource
UITableViewDelegate
Properties
Methods
numberOfSections(in:)
open func numberOfSections(in tableView: UITableView) -> Int
返回Section
的个数 默认返回Group
的总数
tableView(_:numberOfRowsInSection:)
open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
返回对应Section
的Row
的个数 默认返回对应Section
中UITableViewCell
的总数
tableView(_:cellForRowAt:)
open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
返回对应Group
中Cell
的UITableViewCell
第一步会将获取重用或者新创建的UITableViewCell
通过配置闭包进行数据配置
第二步 如果实现了AutomaticDimensionCell
检测设置的高度为UITableView.automaticDimension
并且还没有初始化高度 则进行初始化高度
tableView(_:didSelectRowAt:)
open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
点击UITableViewCell
回掉
tableView(_:heightForRowAt:)
open func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
设置UITableViewCell
的高度
第一步检查是否设置自定义高度 如果设置则返回自定义高度
第二部 如果存在自动计算高度 并且height == UITableView.automaticDimension
则返回自动计算高度
第三部 如果第一步和第二部都不符合 则返回对应height
高度
tableView(_:viewForHeaderInSection:)
open func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
配置Header
tableView(_:heightForHeaderInSection:)
open func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
设置Header
高度