CollectionViewController

open class CollectionViewController : StatefulViewController

A StatefulViewController subclass that manages a collection view.

This class has an associated value depending on the associated value of its collection view controller.

A refresh control is added in the collection view to capture pull to refresh events which will call the refreshContent(completion:) of the collection controller. If there is an error during the refresh, the showRefreshError(title:, message:) by default will show an alert with the error information. The localize description of the error will be passed as the message with no title.

Note

Being a subclass of a NibViewController, an associated nib file is required with outlets connected.

IBOutlets

  • A stack view that holds both the collection view and search bar container view.

    The stack view’s axis is set to vertical by default.

    Declaration

    Swift

    @IBOutlet
    public var containerStackView: UIStackView!
  • The search bar.

    Declaration

    Swift

    @IBOutlet
    public var searchBar: UISearchBar?
  • The collection view.

    Declaration

    Swift

    @IBOutlet
    public var collectionView: UICollectionView!

Properties

  • The refresh control attached to the collection view for pull to refresh events.

    Declaration

    Swift

    open lazy var refreshControl: UIRefreshControl { get set }
  • Determines whether the collection has search enabled.

    Declaration

    Swift

    open var searchEnabled: Bool { get set }
  • The collection controller.

    This casts the contentLoader property to a CollectionController and returns it.

    Declaration

    Swift

    open var collectionController: CollectionController? { get set }

Initializers

  • Returns a newly initialized collection view controller with the specified collection controller.

    Declaration

    Swift

    public convenience init(collectionController: CollectionController?)

    Parameters

    collectionController

    The collection controller to associate with.

    Return Value

    The initialized collection view controller.

Lifecycle

  • Declaration

    Swift

    override open func setup()
  • Undocumented

    Declaration

    Swift

    override open func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)

Actions

Open Methods

  • Configures the search bar.

    This method either hides or shows the search bar depending on the value of the searchEnabled property.

    Declaration

    Swift

    open func setupSearchBar()