Instance Method


Asks the layout object if changes to a self-sizing cell require a layout update.


- (BOOL)shouldInvalidateLayoutForPreferredLayoutAttributes:(UICollectionViewLayoutAttributes *)preferredAttributes withOriginalAttributes:(UICollectionViewLayoutAttributes *)originalAttributes;



The layout attributes returned by the cell’s preferredLayoutAttributesFittingAttributes: method.


The attributes that the layout object originally suggested for the cell.

Return Value

YES if the layout should be invalidated or NO if it should not.


When a collection view includes self-sizing cells, the cells are given the opportunity to modify their own layout attributes before those attributes are applied. A self-sizing cell might do this to specify a different cell size than the one the layout object provides. When the cell provides a different set of attributes, the collection view calls this method to determine if the cell’s change requires a larger layout refresh.

If you are implementing a custom layout, you can override this method and use it to determine if your layout should be invalidated based on the specified attributes. The default implementation of this method returns NO.

See Also

Invalidating the Layout

- invalidateLayout

Invalidates the current layout and triggers a layout update.

- invalidateLayoutWithContext:

Invalidates the current layout using the information in the provided context object.


Returns the class to use when creating an invalidation context for the layout.

- shouldInvalidateLayoutForBoundsChange:

Asks the layout object if the new bounds require a layout update.

- invalidationContextForBoundsChange:

Returns a context object that defines the portions of the layout that should change when a bounds change occurs.

- invalidationContextForPreferredLayoutAttributes:withOriginalAttributes:

Returns a context object that identifies the portions of the layout that should change in response to dynamic cell changes.

- invalidationContextForInteractivelyMovingItems:withTargetPosition:previousIndexPaths:previousPosition:

Returns a context object that identifies the items that are being interactively moved in the layout.