ReusableViewConfigProtocol
public protocol ReusableViewConfigProtocol
An instance conforming to ReusableViewConfigProtocol
is responsible for initializing
and configuring reusable views to be displayed in either a UICollectionView
or a UITableView
.
-
The type of elements backing the collection view or table view.
Declaration
Swift
associatedtype Item
-
The type of views that the configuration produces.
Declaration
Swift
associatedtype View : ReusableViewProtocol
-
Provides a view reuse identifer for the given item, type, and indexPath.
Declaration
Swift
func reuseIdentiferFor(item: Item?, type: ReusableViewType, indexPath: IndexPath) -> String
Parameters
item
The item at
indexPath
.type
The type of reusable view.
indexPath
The index path that specifies the location of the view.
Return Value
An identifier for a reusable view.
-
Configures and returns the specified view.
Declaration
Swift
@discardableResult func configure(view: View, item: Item?, type: ReusableViewType, parentView: View.ParentView, indexPath: IndexPath) -> View
Parameters
view
The view to configure.
item
The item at
indexPath
.type
The type of reusable view.
parentView
The collection view or table view requesting this information.
indexPath
The index path that specifies the location of
view
anditem
.Return Value
A configured view of type
View
.
-
tableCellFor(item:tableView:indexPath:)
Extension methodCreates a new
View
instance, or dequeues an existing cell for reuse, then configures and returns it.Declaration
Parameters
item
The item at
indexPath
.tableView
The table view requesting this information.
indexPath
The index path that specifies the location of the cell and item.
Return Value
An initialized or dequeued, and fully configured table cell.
-
collectionCellFor(item:collectionView:indexPath:)
Extension methodCreates a new
View
instance, or dequeues an existing cell for reuse, then configures and returns it.Declaration
Parameters
item
The item at
indexPath
.collectionView
The collection view requesting this information.
indexPath
The index path that specifies the location of the cell and item.
Return Value
An initialized or dequeued, and fully configured collection cell.
-
supplementaryViewFor(item:kind:collectionView:indexPath:)
Extension methodCreates a new
View
instance, or dequeues an existing view for reuse, then configures and returns it.Declaration
Parameters
item
The item at
indexPath
.kind
The kind of supplementary view to retrieve.
collectionView
The collection view requesting this information.
indexPath
The index path that specifies the location of the view and item.
Return Value
An initialized or dequeued, and fully configured supplementary view.