UICollectionView.RegisterClassForCell Method

Definition

Overloads

Name Description
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);
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 cellType, 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 CGRect parameter, this is used to initialize the class from an object allocated by Objective-C.

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

Applies to

RegisterClassForCell(Type, String)

Specifies the type to be used to populate cells.

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

Parameters

cellType
Type

A subtype of UICollectionViewCell.

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 cellType, 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 CGRect parameter, this is used to initialize the class from an object allocated by Objective-C.

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

Applies to