UICollectionViewLayoutInvalidationContext Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 7.0 and later.
Declared in
UICollectionViewLayout.h

Overview

A UICollectionViewLayoutInvalidationContext object declares which parts of your layout need to be updated when the layout is invalidated. Layout objects that are designed to support invalidation contexts can use that information to optimize their behavior during the invalidation cycle.

You can create an invalidation context object as a precursor to invalidating a layout object. After configuring the invalidation context object, pass it to the layout object’s invalidateLayoutWithContext: method, which is responsible for using the context object to update the layout efficiently. The collection view also creates invalidation contexts in response to specific changes. For example, it creates an invalidation context when you change the layout or data source object, when you insert or delete items, and when you call the reloadData method.

Subclassing Notes

If you create your own custom layout objects, you can subclass UICollectionViewLayoutInvalidationContext and add properties to specify which aspects of your layout data can be invalidated separately. You must then design your layout object to check for these properties and update the layout appropriately.

For more information about how to support custom invalidation contexts in your layout objects, see UICollectionViewLayout Class Reference.

Tasks

Invalidating the Collection View Data

Properties

invalidateDataSourceCounts

A Boolean that indicates whether the layout should ask for new section and item counts. (read-only)

@property (nonatomic, readonly) BOOL invalidateDataSourceCounts
Discussion

You do not set this property yourself. The collection view sets it in response to specific types of layout invalidation scenarios. For example, the collection view sets it to YES when you insert or delete items or call the collection view’s reloadData method.

If this property is set to YES, the layout object should query its delegate for the number of sections and items and update its layout based on the new number of items.

Availability
  • Available in iOS 7.0 and later.
Declared In
UICollectionViewLayout.h

invalidateEverything

A Boolean that indicates that all layout data should be marked as invalid. (read-only)

@property (nonatomic, readonly) BOOL invalidateEverything
Discussion

You do not set this property yourself. The collection view sets it in response to specific types of layout invalidation scenarios. For example, the collection view sets it to YES when you change the current layout object, change the data source of the collection view, or call the reloadData method and subsequently request a layout invalidation context.

If this property is set to YES, the layout object should recompute all of its layout-related data.

Availability
  • Available in iOS 7.0 and later.
Declared In
UICollectionViewLayout.h