Class
UICollectionViewLayoutInvalidationContext
A context object that declares which parts of your layout need to be updated when the layout is invalidated.
--一个用于无效化的上下文对象,声明当布局无效时需要更新布局的哪些部分。
Declaration
class UICollectionViewLayoutInvalidationContext : NSObject
Overview --概览
Layout objects that are designed to support invalidation contexts can use the information in a UICollectionViewLayoutInvalidationContext
object 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 invalidateLayout(with:)
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.
--设计用来支持“无效上下文”的布局对象可以使用uiCollectionViewLayoutValidationContext对象中的信息来优化它们在无效化的运行循环期间的行为。你可以创建“无效上下文”对象,作为无效化布局对象的前兆。配置“无效上下文对象”后,将其传递给布局对象的invalidateLayout(with:)
方法,★ 该方法负责使用该上下文对象高效地更新布局 ★。 collection view也是创建“无效上下文”来响应某些的布局变化。例如,当您更改布局或数据源对象、插入或删除items以及调用reloadData()
方法时,collection view会创建无效上下文。
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.
--如果您创建自己的自定义布局对象,您可以子类化UICollectionViewLayoutInvalidationContext,并添加属性来指定布局数据的哪些方面可以单独失效。然后必须设计布局对象来检查这些属性并适当地更新布局。
For more information about how to support custom invalidation contexts in your layout objects, see UICollectionViewLayout
.
--有关如何在布局对象中支持自定义无效上下文的详细信息,请参阅超链接。
Topics --专题
Invalidating the Collection View Data --无效化collection view的数据
var invalidateEverything: Bool
A Boolean that indicates that all layout data should be marked as invalid.
var invalidateDataSourceCounts: Bool
A Boolean that indicates whether the layout should ask for new section and item counts.
Invalidating the Content Area --无效化内容区域
var contentOffsetAdjustment: CGPoint
The delta value to be applied to the collection view’s content offset.
var contentSizeAdjustment: CGSize
The delta value to be applied to the collection view’s content size.
Invalidating Specific Items --无效后指定的items
func invalidateItems(at: [IndexPath])
Adds the cells at the specified index paths to the list of invalid items.
func invalidateSupplementaryElements(ofKind: String, at: [IndexPath])
Adds the supplementary views at the specified index paths to the list of invalid items.
func invalidateDecorationElements(ofKind: String, at: [IndexPath])
Adds the decoration views at the specified index paths to the list of invalid items.
var invalidatedItemIndexPaths: [IndexPath]?
An array of index paths representing the cells that were invalidated.
var invalidatedSupplementaryIndexPaths: [String : [IndexPath]]?
A dictionary that identifies the supplementary views that were invalidated.
var invalidatedDecorationIndexPaths: [String : [IndexPath]]?
A dictionary that identifies the decoration views that were invalidated.
Invalidating the Order of Items --无效化items的顺序
var previousIndexPathsForInteractivelyMovingItems: [IndexPath]?
An array of index paths representing the previous location of moving items in the collection view.
var targetIndexPathsForInteractivelyMovingItems: [IndexPath]?
An array of index paths representing the new location of moving items in the collection view.
var interactiveMovementTarget: CGPoint
The current point used to determine the placement of moving items.
Relationships --继承关系
Inherits From
Conforms To
See Also
Layout Updates
class UICollectionViewUpdateItem
An object that describes a single change to make to an item in a collection view.
class UICollectionViewFocusUpdateContext
A context object that stores information specific to a focus update in a collection view.
class UICollectionViewFlowLayoutInvalidationContext
A set of properties for determining whether to recompute the size of items or their position in the layout.