Reputation: 8002
Looking through UICollectionView tutorials, I see some where UICollectionViewCell
is subclassed for items, and some where UICollectionReusableView
is subclassed instead. The docs don't make it very clear when you would use one over the other.
Upvotes: 12
Views: 8624
Reputation: 534950
Actually, Apple recommends that you use UICollectionViewCell
both for cells and for supplementary views. That way, you get the useful features such as the background view. UICollectionReusableView
is merely what makes these views reusable. So there is no important distinction except for the built-in superclass–subclass relationship.
Upvotes: 3
Reputation: 38833
UICollectionViewCell
A UICollectionViewCell object presents the content for a single data item when that item is within the collection view’s visible bounds. You can use this class as-is or subclass it to add additional properties and methods. The layout and presentation of cells is managed by the collection view and its corresponding layout object.
UICollectionReusableView
The UICollectionReusableView class defines the behavior for all cells and supplementary views presented by a collection view. Reusable views are so named because the collection view places them on a reuse queue rather than deleting them when they are scrolled out of the visible bounds. Such a view can then be retrieved and repurposed for a different set of content.
So the difference is that a UICollectionViewCell
presents the content for a single data item and a UICollectionReusableView
class defines the behavior for all cells and supplementary views presented by a collection view.
Upvotes: 12