iOS Guides | Samples

MonoTouch.UIKit.UICollectionReusableView Class

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

See Also: UICollectionReusableView

Syntax

[MonoTouch.Foundation.Register("UICollectionReusableView", true)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 6, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
public class UICollectionReusableView : UIView

See Also

Remarks

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

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

Supplementary Views are views that present information associated with each section of a UICollectionView. Like UICollectionViewCells, Supplementary Views are data-driven. Where 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 UICollectionView. Since the 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 UILabel's UILabel.Text property is set to the value of the 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

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.UICollectionReusableView are listed below.

See Also: UIView

Public Constructors

Default constructor, initializes a new instance of this class.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
Initializes the UICollectionReusableView with the specified frame.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

[read-only]
static
AppearanceUICollectionReusableView+UICollectionReusableViewAppearance. Strongly-typed property that returns the UIAppearance class for this class.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
[read-only]
ReuseIdentifierNSString. Used to specify kinds of UICollectionReusableView's that may be reused by the queue.

Public Methods

static
AppearanceWhenContainedIn(params Type[]) : UICollectionReusableView+UICollectionReusableViewAppearance
Returns a strongly typed UIAppearance for instances of this class when the view is hosted in the specified hierarchy.
ApplyLayoutAttributes(UICollectionViewLayoutAttributes)
Applies the specified layout attributes to this UICollectionReusableView.
DidTransition(UICollectionViewLayout, UICollectionViewLayout)
Indicates that a transition has completed.
static
GetAppearance(UITraitCollection) : UICollectionReusableView+UICollectionReusableViewAppearance
Returns an appearance proxy for the specified traits.
static
GetAppearance(UITraitCollection, params Type[]) : UICollectionReusableView+UICollectionReusableViewAppearance
Returns an appearance proxy for the specified traits when found in the containers containment hierarchy.
static
GetAppearance<T>() : UICollectionReusableView+UICollectionReusableViewAppearance
Obtains the appearance proxy UICollectionReusableViewAppearance for the subclass of UICollectionReusableView.
static
GetAppearance<T>(UITraitCollection) : UICollectionReusableView+UICollectionReusableViewAppearance
Obtains the appearance proxy UICollectionReusableViewAppearance for the subclass of UICollectionReusableView.
static
GetAppearance<T>(UITraitCollection, params Type[]) : UICollectionReusableView+UICollectionReusableViewAppearance
Obtains the appearance proxy UICollectionReusableViewAppearance for the subclass of UICollectionReusableView that has the specified trait collection when the view is hosted in the specified hierarchy.
static
GetAppearance<T>(UITraitCollection, params Type[]) : UICollectionReusableView+UICollectionReusableViewAppearance
Obtains the appearance proxy UICollectionReusableViewAppearance for the subclass of UICollectionReusableView that has the specified trait collection when the view is hosted in the specified hierarchy.
PreferredLayoutAttributesFittingAttributes(UICollectionViewLayoutAttributes) : UICollectionViewLayoutAttributes
Called to allow the cell to change the layout attributes.
PrepareForReuse()
Called prior to this UICollectionReusableView being reused by the UICollectionView's reuse queue.
WillTransition(UICollectionViewLayout, UICollectionViewLayout)
Indicates that a transition will shortly begin.