0414--iOS之UICollectionViewLayoutInvalidationContext类

UICollectionViewLayoutInvalidationContext是iOS中用于标记布局需要更新的部分的上下文对象。它可以帮助优化在invalidation周期中的布局行为。当布局、数据源改变,或者插入、删除items时,系统会创建此上下文。可以通过子类化来定制需要单独失效的布局数据,并通过特定方法更新布局。该类涉及的内容包括:数据无效化、内容区域无效化、特定items无效化以及items顺序无效化。
摘要由CSDN通过智能技术生成

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

NSObject

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.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值