Modifier

Partager via


UICollectionView.RegisterClassForCell Method

Definition

Overloads

RegisterClassForCell(Type, NSString)

Specifies the type to be used to populate cells.

RegisterClassForCell(Type, String)

Specifies the type to be used to populate cells.

RegisterClassForCell(Type, NSString)

Specifies the type to be used to populate cells.

public void RegisterClassForCell (Type cellType, Foundation.NSString reuseIdentifier);
member this.RegisterClassForCell : Type * Foundation.NSString -> unit

Parameters

cellType
Type

A subtype of UICollectionViewCell.

reuseIdentifier
NSString

A non-empty string to be associated with the cellType.

Remarks

The UICollectionView maintains a highly-efficient reuse queue for offscreen components. This requires that the UICollectionView be responsible for the lifecycle management of its component views. This method (and related methods such as RegisterClassForSupplementaryView(Type, UICollectionElementKindSection, String)) provide the UICollectionView the knowledge of which types it needs to instantiate.

The application developer may pass null as the reuseIdentifier, in which case the cellType will be "un-registered" and no longer instantiated. The application developer may pass in a reuseIdentifier previously associated with another type, in which case the old type will be "de-registered" and the new cellType will be used.

It is very important that the type that you specify implements a public constructor that takes a RectangleF parameter, this is used to initialize the class from an object allocated by Objective-C. The following example shows the constructor in use:

public class AnimalCell : UICollectionViewCell
{
[Export ("initWithFrame:")]
  public AnimalCell (RectangleF frame) : base (frame) {}
}

Developers should not call this method if they have prototyped their UICollectionViewCell type using a Storyboard. If they do so, they will overwrite the Storyboard-defined definition instantiation of the UICollectionViewCell object's children.

See also

  • <xref:UIKit.UICollectionView.RegisterClassForSupplementaryView>
  • <xref:UIKit.UICollectionView.RegisterNibForCell>
  • <xref:UIKit.UICollectionView.RegisterNibForSupplementaryView>
  • <xref:UIKit.UICollectionViewLayout.RegisterClassForDecorationView>
  • <xref:UIKit.UICollectionViewLayout.RegisterNibForDecorationView>

Applies to

RegisterClassForCell(Type, String)

Specifies the type to be used to populate cells.

public void RegisterClassForCell (Type cellType, string reuseIdentifier);
member this.RegisterClassForCell : Type * string -> unit

Parameters

cellType
Type
reuseIdentifier
String

A non-empty string to be associated with the cellType.

Remarks

The UICollectionView maintains a highly-efficient reuse queue for offscreen components. This requires that the UICollectionView be responsible for the lifecycle management of its component views. This method (and related methods such as RegisterClassForSupplementaryView(Type, UICollectionElementKindSection, String)) provide the UICollectionView the knowledge of which types it needs to instantiate.

The application developer may pass null as the reuseIdentifier, in which case the cellType will be "un-registered" and no longer instantiated. The application developer may pass in a reuseIdentifier previously associated with another type, in which case the old type will be "de-registered" and the new cellType will be used.

It is very important that the type that you specify implements a public constructor that takes a RectangleF parameter, this is used to initialize the class from an object allocated by Objective-C. The following example shows the constructor in use:

public class AnimalCell : UICollectionViewCell
{
[Export ("initWithFrame:")]
  public AnimalCell (RectangleF frame) : base (frame) {}
}

Developers should not call this method if they have prototyped their UICollectionViewCell type using a Storyboard. If they do so, they will overwrite the Storyboard-defined definition instantiation of the UICollectionViewCell object's children.

See also

  • <xref:UIKit.UICollectionView.RegisterClassForSupplementaryView>
  • <xref:UIKit.UICollectionView.RegisterNibForCell>
  • <xref:UIKit.UICollectionView.RegisterNibForSupplementaryView>
  • <xref:UIKit.UICollectionViewLayout.RegisterClassForDecorationView>
  • <xref:UIKit.UICollectionViewLayout.RegisterNibForDecorationView>

Applies to