UITableViewAdapter
open class UITableViewAdapter : NSObject, Adapter
An adapter for UITableView
.
It can be inherited to implement customized behavior or give some unimplemented
methods of delegate or dataSource.
Attention : In UIKit, if inheriting the @objc class which using generics, the delegate and dataSource are don’t work properly, so this class doesn’t use generics, and also the class inherited this class shouldn’t use generics.
-
The data to be rendered in the list UI.
Declaration
Swift
public var data: [Section]
-
A closure that to handle selection events of cell.
Declaration
Swift
open var didSelect: ((UITableViewAdapter.SelectionContext) -> Void)?
-
Create an adapter with initial data.
Declaration
Swift
public init(data: [Section] = [])
Parameters
data
An initial data to be rendered.
-
Returns a registration info for register each cells.
Declaration
Swift
open func cellRegistration(tableView: UITableView, indexPath: IndexPath, node: CellNode) -> CellRegistration
Parameters
tableView
A table view to register cell.
indexPath
An index path for the cell.
node
A node representing cell.
Return Value
A registration info for each cells.
-
Returns a registration info for register each header views.
Declaration
Swift
open func headerViewRegistration(tableView: UITableView, section: Int, node: ViewNode) -> ViewRegistration
Parameters
tableView
A table view to register header view.
section
A index of section for the header view.
node
A node representing header view.
Return Value
A registration info for each header views.
-
Returns a registration info for register each footer views.
Declaration
Swift
open func footerViewRegistration(tableView: UITableView, section: Int, node: ViewNode) -> ViewRegistration
Parameters
tableView
A table view to register footer view.
section
A index of section for the footer view.
node
A node representing footer view.
Return Value
A registration info for each footer views.
-
Return the number of sections.
Declaration
Swift
open func numberOfSections(in tableView: UITableView) -> Int
-
Return the number of rows in specified section.
Declaration
Swift
open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
-
Resister and dequeue the cell at specified index path.
Declaration
Swift
open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
-
Resister and dequeue the header in specified section.
Declaration
Swift
open func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
-
Resister and dequeue the footer in specified section.
Declaration
Swift
open func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView?
-
Returns the height for row at specified index path.
Declaration
Swift
open func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
-
Returns the estimated height for row at specified index path.
Declaration
Swift
public func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat
-
Returns the height for header in specified section.
Declaration
Swift
open func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
-
Returns the estimated height for header in specified section.
Declaration
Swift
open func tableView(_ tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -> CGFloat
-
Returns the height for footer in specified section.
Declaration
Swift
open func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat
-
Returns the estimated height for footer in specified section.
Declaration
Swift
open func tableView(_ tableView: UITableView, estimatedHeightForFooterInSection section: Int) -> CGFloat
-
Callback the selected event of cell to the
didSelect
closure.Declaration
Swift
open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
-
The event that the cell will display in the visible rect.
Declaration
Swift
open func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
-
The event that the cell did left from the visible rect.
Declaration
Swift
open func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath)
-
The event that the header will display in the visible rect.
Declaration
Swift
open func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int)
-
The event that the header did left from the visible rect.
Declaration
Swift
open func tableView(_ tableView: UITableView, didEndDisplayingHeaderView view: UIView, forSection section: Int)
-
The event that the footer will display in the visible rect.
Declaration
Swift
open func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int)
-
The event that the footer did left from the visible rect.
Declaration
Swift
open func tableView(_ tableView: UITableView, didEndDisplayingFooterView view: UIView, forSection section: Int)