See Also: UICollectionViewDelegate Members
Methods within UIKit.UICollectionViewDelegate are called in reaction to events occurring within an associated UIKit.UICollectionView. To use this class, you must derive from it and override its method to respond to events.
Although UIKit.UICollectionView is a subtype of UIKit.UIScrollView, UIKit.UICollectionViewDelegate is not a subtype of UIKit.UIScrollViewDelegate. Nonetheless, many of the methods in UIKit.UICollectionViewDelegate mirror those of UIKit.UIScrollViewDelegate and application developers may find it useful to consult the documentation of that class for a more detailed discussion of methods relating to scrolling.
The UIKit.UICollectionViewSource class provides an alternative to this class, combining the UIKit.UICollectionViewDelegate API and the UIKit.UICollectionViewDataSource APIs. It is available via the UICollectionView.Source property.
Selecting and highlighting in a UIKit.UICollectionView follows this sequence:
User Action | UICollectionViewDelegate Methods | UICollectionViewCell Properties |
---|---|---|
Nothing touched | Highlighted == false; Selected == false | |
Finger down in cell | UICollectionViewDelegate.ShouldHighlightItem is called. If it returns false, processing stops. | |
UICollectionViewDelegate.ItemHighlighted is called. | Highlighted == true; Selected == false | |
Finger up | UICollectionViewDelegate.ShouldSelectItem is called. If it returns false, processing stops. | |
UICollectionViewDelegate.ItemSelected is called. UICollectionViewDelegate.ItemUnhighlighted is called. | Highlighted == false; Selected == true |
Deselecting a UIKit.UICollectionViewCell follows a similar sequence:
User Action | UICollectionViewDelegate Methods | UICollectionViewCell Properties |
---|---|---|
Nothing touched while some UIKit.UICollectionViewCell is highlighted. | Highlighted == false; Selected == true | |
Finger taps cell (Deselect gesture) | UICollectionViewDelegate.ShouldDeselectItem is called. If it returns false, processing stops. | |
UICollectionViewDelegate.ItemDeselected is called. | Highlighted == false; Selected == false |