prepare(forCollectionViewUpdates:)
Performs needed tasks before items are inserted, deleted, or moved within the collection view.
Declaration
func prepare(forCollectionViewUpdates updateItems: [NSCollectionViewUpdateItem])Parameters
- updateItems:
An array of Nscollectionviewupdateitem objects that identify the changes being made.
Discussion
When items are inserted, deleted, or moved, the collection view calls this method to report those changes to the layout object. The default implementation uses the provided information to plan the layout animations needed to respond to the changes. Subclasses can override this method and use it to prepare for any custom changes, but you should always call super at some point in your implementation.
See Also
Responding to Collection View Updates
finalizeCollectionViewUpdates()indexPathsToInsertForSupplementaryView(ofKind:)indexPathsToInsertForDecorationView(ofKind:)initialLayoutAttributesForAppearingItem(at:)initialLayoutAttributesForAppearingSupplementaryElement(ofKind:at:)initialLayoutAttributesForAppearingDecorationElement(ofKind:at:)indexPathsToDeleteForSupplementaryView(ofKind:)indexPathsToDeleteForDecorationView(ofKind:)finalLayoutAttributesForDisappearingItem(at:)finalLayoutAttributesForDisappearingSupplementaryElement(ofKind:at:)finalLayoutAttributesForDisappearingDecorationElement(ofKind:at:)