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.

Associated types

  • 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

Methods

  • 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 and item.

    Return Value

    A configured view of type View.

Table cells

  • Creates a new View instance, or dequeues an existing cell for reuse, then configures and returns it.

    Declaration

    Swift

    public func tableCellFor(item: Item, tableView: UITableView, indexPath: IndexPath) -> View

    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.

Collection cells

  • Creates a new View instance, or dequeues an existing cell for reuse, then configures and returns it.

    Declaration

    Swift

    public func collectionCellFor(item: Item, collectionView: UICollectionView, indexPath: IndexPath) -> View

    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.

Supplementary views

  • Creates a new View instance, or dequeues an existing view for reuse, then configures and returns it.

    Declaration

    Swift

    public func supplementaryViewFor(item: Item?, kind: String, collectionView: UICollectionView, indexPath: IndexPath) -> View

    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.