TableView Documentation

Class Table​View.​Data​Source

open class DataSource:NSObject, UITableViewDataSource, UITableViewDelegate  

代理和数据源 如果想自定义或者实现UITableViewDataSource|UITableViewDelegate其他协议方法 请继承重写

TableView.DataSource TableView.DataSource NSObject NSObject TableView.DataSource->NSObject UITableViewDataSource UITableViewDataSource TableView.DataSource->UITableViewDataSource UITableViewDelegate UITableViewDelegate TableView.DataSource->UITableViewDelegate

Member Of

TableView

一个表格的数据源 可以快速搭建基于UITableView的列表或者复杂的UI界面,支持高度自动计算,自动缓存高度,便捷的高度刷新。

Conforms To

NSObject
UITableViewDataSource
UITableViewDelegate

Properties

table​View

public weak var tableView:TableView? 

弱引用的TableView

Methods

number​OfSections(in:​)

open func numberOfSections(in tableView: UITableView) -> Int  

返回Section的个数 默认返回Group的总数

table​View(_:​number​OfRows​InSection:​)

open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int  

返回对应SectionRow的个数 默认返回对应SectionUITableViewCell的总数

table​View(_:​cell​For​Row​At:​)

open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell  

返回对应GroupCellUITableViewCell 第一步会将获取重用或者新创建的UITableViewCell通过配置闭包进行数据配置 第二步 如果实现了AutomaticDimensionCell 检测设置的高度为UITableView.automaticDimension 并且还没有初始化高度 则进行初始化高度

table​View(_:​did​Select​Row​At:​)

open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)  

点击UITableViewCell回掉

table​View(_:​height​For​Row​At:​)

open func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat  

设置UITableViewCell的高度 第一步检查是否设置自定义高度 如果设置则返回自定义高度 第二部 如果存在自动计算高度 并且height == UITableView.automaticDimension则返回自动计算高度 第三部 如果第一步和第二部都不符合 则返回对应height高度

table​View(_:​view​For​Header​InSection:​)

open func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?  

配置Header

table​View(_:​view​For​Footer​InSection:​)

open func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView?  

配置Footer

table​View(_:​height​For​Header​InSection:​)

open func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat  

设置Header高度

table​View(_:​height​For​Footer​InSection:​)

open func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat  

设置Footer高度