UICollectionViewAdapter
open class UICollectionViewAdapter : NSObject, Adapter
An adapter for UICollectionView.
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: ((UICollectionViewAdapter.SelectionContext) -> Void)? -
Create an adapter with initial data.
Declaration
Swift
public init(data: [Section] = [])Parameters
dataAn initial data to be rendered.
-
Returns a registration info for register each cells.
Declaration
Swift
open func cellRegistration(collectionView: UICollectionView, indexPath: IndexPath, node: CellNode) -> CellRegistrationParameters
collectionViewA collection view to register cell.
indexPathAn index path for the cell.
nodeA node representing cell.
Return Value
A registration info for each cells.
-
Returns a registration info for register each header views.
Declaration
Swift
open func supplementaryViewRegistration(forElementKind kind: String, collectionView: UICollectionView, indexPath: IndexPath, node: ViewNode) -> ViewRegistrationParameters
kindThe kind of element for supplementary view.
collectionViewA collection view to register supplementary view.
indexPathAn index path for the supplementary view.
nodeA node representing supplementary view.
Return Value
A registration info for each supplementary views.
-
Returns a node for supplementary view for arbitrary element of kind.
Declaration
Swift
open func supplementaryViewNode(forElementKind kind: String, collectionView: UICollectionView, at indexPath: IndexPath) -> ViewNode?Parameters
kindThe kind of element for supplementary view.
collectionViewA collection view to display supplementary view.
indexPathAn index path for the supplementary view.
nodeA node representing supplementary view.
Return Value
A node for supplementary view for arbitrary element of kind.
-
Returns the kinds of supplementary view registered in the specified collection view.
Declaration
Swift
public func registeredSupplementaryViewKinds(for collectionView: UICollectionView) -> [String]Parameters
collectionViewA collection view that supplementary views registered.
Return Value
The kinds of supplementary view registered in the specified collection view.
-
Return the number of sections.
Declaration
Swift
open func numberOfSections(in collectionView: UICollectionView) -> Int -
Return the number of items in specified section.
Declaration
Swift
open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int -
Resister and dequeue the cell at specified index path.
Declaration
Swift
open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell -
Resister and dequeue the header or footer in specified section.
Declaration
Swift
open func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView
-
Callback the selected event of cell to the
didSelectclosure.Declaration
Swift
open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) -
The event that the cell will display in the visible rect.
Declaration
Swift
open func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) -
The event that the cell did left from the visible rect.
Declaration
Swift
open func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) -
The event that the header or footer will display in the visible rect.
Declaration
Swift
open func collectionView(_ collectionView: UICollectionView, willDisplaySupplementaryView view: UICollectionReusableView, forElementKind elementKind: String, at indexPath: IndexPath) -
The event that the header or footer did left from the visible rect.
Declaration
Swift
open func collectionView(_ collectionView: UICollectionView, didEndDisplayingSupplementaryView view: UICollectionReusableView, forElementOfKind elementKind: String, at indexPath: IndexPath)
View on GitHub
UICollectionViewAdapter Class Reference