Instance Method

dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath:

Returns a reusable supplementary view located by its identifier and kind.

Declaration

- (__kindof UICollectionReusableView *)dequeueReusableSupplementaryViewOfKind:(NSString *)elementKind withReuseIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath;

Parameters

elementKind

The kind of supplementary view to retrieve. This value is defined by the layout object. This parameter must not be nil.

identifier

The reuse identifier for the specified view. This parameter must not be nil.

indexPath

The index path specifying the location of the supplementary view in the collection view. The data source receives this information when it is asked for the view and should just pass it along. This method uses the information to perform additional configuration based on the view’s position in the collection view.

Return Value

A valid UICollectionReusableView object.

Discussion

Call this method from your data source object when asked to provide a new supplementary view for the collection view. This method dequeues an existing view if one is available or creates a new one based on the class or nib file you previously registered.

If you registered a class for the specified identifier and a new cell must be created, this method initializes the cell by calling its initWithFrame: method. For nib-based cells, this method loads the cell object from the provided nib file. If an existing cell was available for reuse, this method calls the cell’s prepareForReuse method instead.

See Also

Creating Collection View Cells

- registerClass:forCellWithReuseIdentifier:

Register a class for use in creating new collection view cells.

- registerNib:forCellWithReuseIdentifier:

Register a nib file for use in creating new collection view cells.

- registerClass:forSupplementaryViewOfKind:withReuseIdentifier:

Registers a class for use in creating supplementary views for the collection view.

- registerNib:forSupplementaryViewOfKind:withReuseIdentifier:

Registers a nib file for use in creating supplementary views for the collection view.

- dequeueReusableCellWithReuseIdentifier:forIndexPath:

Returns a reusable cell object located by its identifier