UIKit.UICollectionReusableView Class
The base class for UIKit.UIViews that are reused in a UIKit.UICollectionView.

See Also: UICollectionReusableView Members


[Foundation.Register("UICollectionReusableView", true)]
public class UICollectionReusableView : UIView

See Also



The UIKit.UICollectionView class is designed to work with large datasets while respecting the resource limitations of iOS devices. To do this, the UIKit.UICollectionView maintains a reuse queue of component views of type UIKit.UICollectionReusableView, instantiating only as many as are strictly necessary and replacing values in UIKit.UICollectionReusableViews that are no longer visible with values appropriate to UIKit.UICollectionReusableViews that are about to scroll onto the screen. (See UIKit.UICollectionView for an extended discussion of the reuse queue.)

The cells in a UIKit.UICollectionView are expected to be of type UIKit.UICollectionViewCell, which is a subtype of UIKit.UICollectionReusableView. Supplementary views, though, are likely to be direct subtypes of UIKit.UICollectionReusableView.

Supplementary Views are views that present information associated with each section of a UIKit.UICollectionView. Like UIKit.UICollectionViewCells, Supplementary Views are data-driven. Where UIKit.UICollectionViewCells present the item data from a data source, Supplementary Views present the section data, such as the categories of book in a bookshelf or the genre of music in a music library.

For example, a Supplementary View could be used to present a header for a particular section, as shown in this figure taken from the "Introduction to Collection Views" guide:

However, Supplementary Views are more generic than just headers and footers. They can be positioned anywhere in the collection view and can be comprised of any views, making their appearance fully customizable.

Supplementary Views are associated with specific sections within the UIKit.UICollectionView. Since the UIKit.UICollectionView manages the reuse queue and will reuse an off-screen supplementary view, the application developer can use the UICollectionViewDataSource.GetViewForSupplementaryElement method to coordinate the visual attributes of a supplementary view with domain data from a model element. In the following code, a UIKit.UILabel's UILabel.Text property is set to the value of the Foundation.NSIndexPath.Section property.

C# Example

          public override UICollectionReusableView GetViewForSupplementaryElement (UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
            var headerView = (Header) collectionView.DequeueReusableSupplementaryView (elementKind, headerId, indexPath);
            headerView.Text = "Supplementary View Section " + indexPath.Section.ToString ();
            return headerView;

Related content


Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: