Class
TableView.Cell
public class Cell
Group添加Cell配置
Relationships
Member Of
TableView一个表格的数据源 可以快速搭建基于
UITableView的列表或者复杂的UI界面,支持高度自动计算,自动缓存高度,便捷的高度刷新。
Nested Type Aliases
CustomHeightHandle
public typealias CustomHeightHandle<D> = (_ tableView:UITableView,
_ cell:TableView.Cell,
_ data:D,
_ indexPath:IndexPath,
_ index:Int) -> CGFloat
自定义高度的回掉
Parameters
| Name | Type | Description |
|---|---|---|
| tableView | 对应所在的 |
|
| cell | 对应 |
|
| data | 对应的设置数据 |
|
| indexPath |
|
|
| index | 对应在 |
ConfigBlock
public typealias ConfigBlock<C:UITableViewCell, D> = (_ tableView:UITableView,
_ tableViewCell:C,
_ data:D,
_ indexPath:IndexPath,
_ index:Int) -> Void
配置UITableViewCell回掉
Parameters
| Name | Type | Description |
|---|---|---|
| tableView | 所在的 |
|
| tableViewCell | 需要配置的 |
|
| data | 需要设置的数据 |
|
| indexPath |
|
|
| index |
|
DidSelectBlock
public typealias DidSelectBlock<C:UITableViewCell,D> = (_ tableView:UITableView,
_ tableViewCell:C,
_ data:D,
_ indexPath:IndexPath,
_ index:Int) -> Void
点击UITableViewCell回掉
Parameters
| Name | Type | Description |
|---|---|---|
| tableView | 所在的 |
|
| tableViewCell | 点击的 |
|
| data | 对应的数据 |
|
| indexPath |
|
|
| index |
|
Properties
data
public var data:[Any] = []
设置数据源 必须是数组类型 如果数据统一放在数组里面 可以放类型String或者Int的占位符,因为获取对应UITableViewCell的个数是通过这个属性的.count进行设置的
height
public var height:CGFloat = UITableView.automaticDimension
设置Cell中对应UITableViewCell的高度,默认为UITableView.automaticDimension。如果实现了自动计算高度的协议,则自动计算高度。一旦设置了height的值不等于UITableView.automaticDimension,则返回设置的高度,内部不会自动计算高度
Methods
config(_:_:_:)
public func config<T:UITableViewCell, D>(_ cellType:T.Type,
_ dataType:D.Type,
_ block:@escaping ConfigBlock<T,D>)
进行配置UITableViewCell
Parameters
| Name | Type | Description |
|---|---|---|
| cellType | T.Type |
|
| dataType | D.Type |
数据的类型 |
| block | @escaping ConfigBlock<T,D> |
配置的闭包 |
configCell(tableView:cell:indexPath:index:)
public func configCell<C:UITableViewCell>(tableView:UITableView,
cell:C,
indexPath:IndexPath,
index:Int)
主动调用去配置UITableViewCell
Parameters
| Name | Type | Description |
|---|---|---|
| tableView | UITableView |
所在的 |
| cell | C |
所在的 |
| indexPath | IndexPath |
|
| index | Int |
|
didSelect(_:_:_:)
public func didSelect<T:UITableViewCell, D>(_ cellType:T.Type,
_ dataType:D.Type,
_ block:@escaping DidSelectBlock<T,D>)
点击UITableViewCell
Parameters
| Name | Type | Description |
|---|---|---|
| cellType | T.Type |
|
| dataType | D.Type |
数据类型 |
| block | @escaping DidSelectBlock<T,D> |
点击回掉 |
height(_:_:)
public func height<D>(_ dataType:D.Type,
_ block:@escaping CustomHeightHandle<D>)
自定义高度
Parameters
| Name | Type | Description |
|---|---|---|
| dataType | D.Type |
数据类型 |
| block | @escaping CustomHeightHandle<D> |
自定义高度闭包 |